[SOLVED] grep semi-variable pattern
by Drosera_capensis from LinuxQuestions.org on (#5P9GY)
Hello everyone,
I have used grep to process data from this input:
Code:Scaffolds_16_pilon ACmerged_contig_2215 5_1009.75816 11_1010 11_1011To that output:
Code:Scaffolds_16_pilon ACmerged_contig_2215 1 5
Scaffolds_16_pilon ACmerged_contig_2215 2 11Part of my script is based on selection the correct first number before the underscore in column three and four.
For this I have used the regexp '$f'_.* to select a specific $f followed by underscore, then a variable pattern.
Code:grep --only-matching '\<'$f'_.*\>' | wc --word
Unfortunately, when $f=5 the script select the three last column and not just the first one. And I don't really understand why. Any idea anyone?
I have used grep to process data from this input:
Code:Scaffolds_16_pilon ACmerged_contig_2215 5_1009.75816 11_1010 11_1011To that output:
Code:Scaffolds_16_pilon ACmerged_contig_2215 1 5
Scaffolds_16_pilon ACmerged_contig_2215 2 11Part of my script is based on selection the correct first number before the underscore in column three and four.
For this I have used the regexp '$f'_.* to select a specific $f followed by underscore, then a variable pattern.
Code:grep --only-matching '\<'$f'_.*\>' | wc --word
Unfortunately, when $f=5 the script select the three last column and not just the first one. And I don't really understand why. Any idea anyone?