I have a fairly complex text file file1.txt
that hasn't been munged properly. The file is tab-delimited however, i.e. each string is separated by \t
.
I would like to write a script/use a Unix command that parses this entire file for a certain string string1:
which will print the line after the colon until stopping at \t
.
The text file looks like this:
...kjdafhldkhlfak\tSTRING1:Iwanttokeepthis\tfadfasdafldafh\tSTRING1:andthis\tafsdkfasldh....
So the grep
like function outputs
Iwanttokeepthis
andthis
In Perl, I know how to print a string if it occurs with
perl -wln -e 'print if /\bSTRING1\b/' file1.txt
How would one revise this to print the line between STRING1:
and \t
?