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HFSKALELAFATQQFVALQLIAEDLDETSDPALLARCSDFFIEHSQYERAVELLLAARKYQEALQLCLGQNMSITEEMAEKMTVAKDSSDLPEESRRELLEQIADCCMRQGSYHLATKKYTQAGNKLKAMRALLKSGDTEKITFFASVSRQKEIYIMAANYLQSLDWRKEPEIMKNIIGFYTKGRALDLLAGFYDACAQVEIDEYQNYDKAHGALTEAYKCLAKAKAKSPLDQETRLAQLQSRMALVKRFIQARRTYTEDPKESIKQCELLLEEPDLDSTIRIGDVYGFLVEHYVRKEEYQTAYRFLEEMRRRLPLANMSYYVSPQAVDAVHRGLGLPLPRTVPEQVRHNSMEDARELDEEVVEEADDDP
I would like to replace index position 383 (Q) with nothing after it, so the desired outcome would be:
MALYYDHQIEAPDAAGSPSFISWHPVHPFLAVAYISTTSTGSVDIYLEQGECVPDTHVERPFRVASLCWHPTRLVLAVGWETGEVTVFNKQDKEQHTMPLTHTADITVLRWSPSGNCLLSGDRLGVLLLWRLDQRGRVQGTPLLKHEYGKHLTHCIFRLPPPGEDLVQLAKAAVSGDEKALDMFNWKKSSSGSLLKMGSHEGLLFFVSLMDGTVHYVDEKGKTTQVVSADSTIQMLFYMEKREALVVVTENLRLSLYTVPPEGKAEEVMKVKLSGKTGRRADIALIEGSLLVMAVGEAALRFWDIERGENYILSPDEKFGFEKGENMNCVCYCKVKGLLAAGTDRGRVAMWRKVPDFLGSPGAEGKDRWALQTPTELQGNITQ
I have tried:
sed 's/"Q"//383' text.file
sed 's/Q//383' text.file
But that does not do anything.
In the long term I need to do with with a few other positions so a method that is flexible would be much appreciated.
All the best
Solution
This might work for you (GNU sed):
sed -zEi 's/(.{383}).*/\1/' file
Store the first 383 characters as a back reference and remove the rest.
N.B. the -z
option slurps the entire file into memory.
Answered By - potong