There is a ‘paste‘ command which is less known and used on Linux shell environment. The ‘paste‘ command doesn’t work as it sounds (copy + paste, cut + paste). Instead, it takes two paramters (file names) and put them together (output to console by default) column by column.
Here is the manual of paste if you type in manual paste on the shell.
Suppose, we have two files, which are:
pi@raspberrypi:~$ cat A 1 2 3 4 5 6 7 8 pi@raspberrypi:~$ cat B A B C D E F G H
If we run paste A B, we ‘ll get:
pi@raspberrypi:~$ paste A B 1 A 2 B 3 C 4 D 5 E 6 F 7 G 8 H pi@raspberrypi:~$
So the two files are concatenated column by column and this is separated by default delimiter, which is TAB.
We can specify the delimiter by using -d switch, something like this paste -d, A B:
pi@raspberrypi:~$ paste -d, A B 1,A 2,B 3,C 4,D 5,E 6,F 7,G 8,H
We can also paste the files in serial instead of parallel, using the -s switch. e.g. paste -s A B:
pi@raspberrypi:~$ paste -s A B 1 2 3 4 5 6 7 8 A B C D E F G H
Combined both, e.g. paste -d, -s A B
pi@raspberrypi:~$ paste -d, -s A B 1,2,3,4,5,6,7,8 A,B,C,D,E,F,G,H
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: Send Keystrokes to the Active Window using SendKeys (WSH)
Next Post: Useful Utility on Windows Shell to Copy Output Content to Clipboard