Apr 15, 2009

unix tool: paste

1. attach line number to a file
seq `wc -l
2. join multiple lines
seq 9 | paste -d" " -s -

3. join two files by columns
paste -d", " <(cut -d", " -f1 $FILE1) <(cut -d"," -f3,4 $FILE2)

Apr 1, 2009

bash script: how to handle command line arguments

There is one example shell script demonstrate how to use getopt (GNU version) to parse command line argument handling. getopt GNU version is able to parse both short and long options. The bash built-in getopts cannot process long option.

This post (in Chinese) is a very good reference for getopt

About Me

My photo