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
Entries Categorized as 'Bash/Shell'
Turning a Multi-Line File Into a CSV File
April 10, 2008 by Isaac
Recursive Find and Replace in Linux
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
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 quotes, each parameter [...]
Using find in Linux
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 [...]
Mounting a remote SSH filesystem
June 5, 2006 by Isaac
On a typical project there are many different computers that I must use. For years I have been using scp to copy files from one computer to another and wishing for a way to just mount the SSH filesystem. Well, my wish finally came true!
The good news is that thanks to sshfs I [...]
Posted in

content rss
