Entries Categorized as 'Bash/Shell'

Turning a Multi-Line File Into a CSV File

Date April 10, 2008 by Isaac

Linux has many amazing programs that can be chained together to produce amazing results. Today I needed to turn a multi-line file into a CSV (comma separated) file. In Linux this is super easy: cat file | tr ‘\n’ ‘,’ Basically, this will turn a file like this: Line1 Line2 Line3 Line4 Into this: Line1,Line2,Line3,Line4

Recursive Find and Replace in Linux

Date September 25, 2006 by Isaac

Believe it or not this actually took some time to find, so I am posting it here for future reference. To do a find and replace recursively in Linux type:   find ./ -type f | xargs sed -i ‘s/string1/string2/g’   That will replace every occurrence of “string1″ with “string2.”

Bash Variables

Date August 17, 2006 by Isaac

Character Definition $* Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, it expands to a single word with the value of each parameter separated by the first character of the IFS special variable. $@ Expands to the positional parameters, starting from one. When the expansion occurs within double [...]

Using find in Linux

Date August 11, 2006 by Isaac

The find command is Linux is seriously cool. It allows you to do so much more than simply locate where a file lives. You can also do nifty stuff like delete all the temporary files on your whole hard drive, find broken links, delete empty files, search within files, and more. You can read about [...]