By yifangt
infile.fq:
@GAIIX-300
ATAGTCAAAT
+
_SZS^\cd
@GAIIX-300
CATACGACAT
+
hhghfdffhh
@GAIIX-300
GACGACGTAT
+
gggfc[hh]f
outfile:
@GAIIX-300 ATAGTCAAAT + _SZS^\cd
@GAIIX-300 CATACGACAT + hhghfdffhh
@GAIIX-300 GACGACGTAT + gggfc[hh]f
I used
sed '/^@/N;/^@/N;/^@/N;s/n/t/g' infile.fq
without full understanding. I figured out this oneliner when I tried to understand newline substitution in sed.
1) Can anyone explain the four consecutive /^@/N for me?
2) How can I use another command tr to do the job like:
!n@ | tr 'n' 't' outfile.tab
by adding the condition !n@ to filter the record separator, which is @ here? I know awk can do the job much easier with RS=”@”, OFS=”t”,
but I want to understand how sed and tr work, if they can, in this case.
Thanks a lot!
YF
…read more
Source: FULL ARTICLE at The UNIX and Linux Forums