regex - Pipe awk's results to sed (deletion) -
regex - Pipe awk's results to sed (deletion) -
i using awk command (someawkcommand) prints these lines (awkoutput):
>genome1 atgcaaaag caataa
and then, want utilize output (awkoutput) input of sed command. that:
someawkcommand | sed 's/awkoutput//g' file1.txt > results.txt
file1.txt:
>genome1 atgcaaaag caataa >genome2 atgaaaaa aaaaaaaa caa >genome3 accc
the final objective delete lines in file (file1.txt
) containing exact pattern found awk.
the file results.txt
contains (output of sed):
>genome2 atgaaaaa aaaaaaaa caa >genome3 accc
how should write sed command? there simple way sed recognize output of awk input?
using gnu awk multi-char rs:
$ cat file1 >genome1 atgcaaaag caataa $ cat file2 >genome1 atgcaaaag caataa >genome2 atgaaaaa aaaaaaaa caa >genome3 accc $ gawk -v rs='^$' -v ors= 'nr==fnr{rmv=$0;next} {sub(rmv,"")} 1' file1 file2 >genome2 atgaaaaa aaaaaaaa caa >genome3 accc
the stuff might non-obvious newcomers mutual awk idioms:
-v rs='^$'
tells awk read whole file 1 string (instead of it's default 1 line @ time). -v ors=
sets output record separator null string (instead of it's default newline) when file printed string awk doesn't add together newline after it. nr==fnr
status true first input file. 1
true status invoking default action of printing current record. regex bash awk sed
Comments
Post a Comment