Saturday, May 09, 2009

The unix paste command

One relatively unknown unix command is paste which I had occasion to use recently. I had to twiddle some data in between 2 fixed length files and the machine did not have vim so that I could use visual block selection and too big to quickly scp to my workstation. With some help from google I discovered paste, which in combination with cut reduced the task to something as simple as this
cut -c 1-32 file1.txt > left
cut -c 48-  file1.txt > right
cut -c 64-108 file2.txt > middle
paste -d '\0' left middle right # do not use the default delimiter instead use null
Finally I managed to refine the entire process into a series of cut and pastes in sequence.

No comments: