Quickly creating a CSV file

Written by Benjamin Cane on 2011-07-19

I have found that a systems administrators job doesn't simply involve managing services and ensuring they are running. Many times the job includes extracting data from files and putting them into a usable form.

Today's example of Shell-Fu is creating a CSV list of the users on the system generated by the /etc/passwd file.

[[email protected] play]$ cat /etc/passwd | cut -d: -f1| perl -pi -e 's/n/,/'  
root,bin,daemon,adm,lp,sync,shutdown,halt,mail,uucp,operator,games,[Continued]

If you wanted to save this to a file you could use > or depending on whether you want to overwrite pre-existing data or not.

> Will overwrite an existing file
>> Will append to an existing file


Picture of Benjamin Cane

Benjamin's specialty is keeping the lights on for mission critical systems. He is currently building applications that enable high concurrency financial transactions.

Recently Benjamin published his first book; Red Hat Enterprise Linux Troubleshooting Guide. In addition to writing, he has several Open Source projects focused on making Ops easier. These projects include Automatron, a project enabling auto-healing infrastructure for the masses.


Publications

Identify, capture and resolve common issues faced by Red Hat Enterprise Linux administrators using best practices and advanced troubleshooting techniques

What people are saying:
Excellent, excellent resource for practical guidance on how to troubleshoot a wide variety of problems on Red Hat Linux. I particularly enjoyed how the author made sure to provide solid background and practical examples. I have a lot of experience on Red Hat but still came away with some great practical tools to add to my toolkit. - Amazon Review