Saturday, April 6, 2013

Linux / unix tips: paste

>paste [-s] [-d delim-list] [--serial] [--delimiters=delim-list] [--help] [--version] [file...]

http://linux.about.com/library/cmd/blcmdl_paste.htm
paste prints lines consisting of sequentially corresponding lines of each specified file. In the output the original lines are separated by TABs. The output line is terminated with a newline.

Example - convert tab-delimited file into csv:
http://askubuntu.com/questions/174008/write-bash-script-which-takes-input-from-pipe
cat some_list_of_elements.txt | awk '{print "\047"$1"\047"}' | paste -d, -s
It takes a list of items from a file, wraps each in quotes, and merges them together in a comma-separated list.

No comments:

Post a Comment