For example:
abc
xyz
123
546
input.txt:
asdad
asdad
adghf
dfytr
I wanted to add the above column in 2nd column. The expected output is given below.
output.txt:
asdad abc
asdad xyz
adghf 123
dfytr 567
For example:
abc
xyz
123
546
input.txt:
asdad
asdad
adghf
dfytr
I wanted to add the above column in 2nd column. The expected output is given below.
output.txt:
asdad abc
asdad xyz
adghf 123
dfytr 567
paste
is the easiest solution. Here's an awk example that doesn't have to store the entire first file in memory:The command you're looking for is
paste
rather thanawk
. You could do it inawk
but you'll probably find thatpaste
is easier:Use
paste -d' ' qq1 qq2
if you want a space rather than a tab for the delimiter.In awk:
Though its probably better to use paste
You can use just
bash