Bash: cutting a delimited fragment of each string
bash, regex
Solution
Try with grep.
This will keep the last 13 characters and then the first 7, returning only the matching characters (-o) with the Perl-compliant -P flag:
grep -oP ".{13}$" foo.txt | grep -oP ".{7}"
Problem
I have a file containing lines that look like this: ``` GTTCAGAGTTCTACAGTCCGACGATCGGATGAGNNNNNN GTTCAGAGTTCTACAGTCCGACGATCTCCGAGTNNNNNN GTTCAGAGTTCTACAGTCCGACGATCCTTATATNNNNNN GTTCAGAGTTCTACAGTCCGACGATCGAAGTGCNNNNNN GTTCAGAGTTCTACAGTCCGACGATCAAGTTTTNNNNNN GTTCAGAGTTCTACAGTCCGACGATCCGACGAANNNNNN ``` I want to remove the first 26 and final 6 characters from each line. I haven't been able to write a good regular expression to accomplish that using vi, but I'm not sure what else to do. Any suggestions? Thanks!