awk - Bash rows to column -
i know how transpose rows in file columns, want append lines of bottom half of file lines upper half.
like:
a1 a2 a3 b1 b2 b3
to
a1 | b1 a2 | b2 a3 | b3
the list comes 2 grep
s. append first grep
sec one. 2 grep
s have same amount of hits.
i want within bash script.
what combining head
, tail
paste
?
paste -d'|' <(head -3 file) <(tail -3 file)
it returns:
a1|b1 a2|b2 a3|b3
paste
merges lines of files. if provide different lines same file... that's all!
as matter of getting head
half of lines , tail
rest, more generic way:
paste -d'|' <(head -n $(($(wc -l <file)/2)) file) <(tail -n $(($(wc -l <file)/2)) file)
bash awk sed grep transpose
No comments:
Post a Comment