Join consequent lines in unix
I have a file like this.John 30 Mike 0.0786268 Tyson 0.114889 Gabriel 0.176072 Fiona 0.101895I need to shift every second row to a new column so it should look like this
John 30 Mike 0.0786268 Tyson 0.114889 Gabriel 0.176072 Fiona 0.101895There can be many solutions for this:
sed:
sed 'N;s/\n/ /g' yourfileAwk:
awk '{if(NR%2!=0){p=""}else{p="\n"};printf $0" "p}' your_filePaste:
paste - - file new_fileMy pick is:
xargs -n2
Dude! You win! I never thought of using xargs like that. Elegant.
ReplyDelete