I have four text files each containing a single field. I want to convert them into a single text file with four fields (one from each file). How can I do this using shell scripting.
Asked
Active
Viewed 1,883 times
2 Answers
3
This should do:
paste file_1 file_2 file_3 file_4
If you want pretty printing (given that the number of lines are same for all the files), then:
paste 1 2 3 4 | column -t
heemayl
- 54,820
- 8
- 124
- 141
-
note that `column` is likely to break things for files that don't have the same number of lines. – peterph Feb 03 '15 at 19:49
-
@peterph: yes, edited. – heemayl Feb 03 '15 at 19:50
-
@peterph - depends what switches his/her version of `column` accepts... see glenn jackman's answer [here](http://unix.stackexchange.com/q/16443) - it works fine with files that don't have the same number of lines. – don_crissti Feb 03 '15 at 21:11
-
@don_crissti *"... is **likely** to break things..."* You'll have to fiddle with it to make sure things will be what you want them to be. – peterph Feb 04 '15 at 13:38