Issue
Hi my files look like:
>ID.1
GGAACACGACATCCTGCAGGGTTAAAAAAGAAAAAATCAGTAAAAGTACTGGA
>ID.2
GGAATACCACATCCCGCAGGGTTAAAAAAGAAAAAATCAGTAACAGTACTGGA
and I want to move the lines so that line 1 swaps with 3, and line 2 swaps with 4.
>ID.2
GGAATACCACATCCCGCAGGGTTAAAAAAGAAAAAATCAGTAACAGTACTGGA
>ID.1
GGAACACGACATCCTGCAGGGTTAAAAAAGAAAAAATCAGTAAAAGTACTGGA
I have thought about using cut
so cut send the lines into other files, and then bring them all back in the desired order using paste
, but is there a solution using awk/sed.
EDIT: The file always has 4 lines (2 fasta entrys), no more.
Solution
Using sed:
sed '1h;2H;1,2d;4G'
- Store the first line in the hold space;
- Add the second line to the hold space;
- Don't print the first two lines;
- Before printing the fourth line, append the hold space to it (i.e. append the 1st and 2nd line).
Answered By - choroba Answer Checked By - Senaida (WPSolving Volunteer)