Joining Line Breaks in FASTA file With Condition in SED/AWK/Perl one-liner
awk, linux, perl, sed, unix
Solution
$ awk '/^>/&&NR>1{print "";}{ printf "%s",/^>/ ? $0" ":$0 }' file
> sq1 foofoofoobarfoofoofoo
> sq2 quxquxquxbarquxquxquxbarquxx
> sq3 paxpaxpaxpax
Problem
I have a data that looks like this ``` > sq1 foofoofoobar foofoofoo > sq2 quxquxquxbar quxquxquxbar quxx > sq3 paxpaxpax pax ``` What I want to do is to join them into one lines: ``` > sq1 foofoofoobarfoofoofoo > sq2 quxquxquxbarquxquxquxbarquxx > sq3 paxpaxpaxpax ``` I tried this code but fail. ``` sed -e 'te' -e 'H;$!d;:e' -e 'x;/^$/d;s/\n//g' ``` What's the right way to do it?