Quickly creating a CSV file

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

About Benjamin

Benjamin is a Infrastructure and Software Engineer. On this blog he writes about Linux, Docker, Programming as well as other Systems topics.

Learn more about Linux

If you liked this article, check out Benjamin's book: Red Hat Enterprise Linux Troubleshooting Guide. Where you can learn a lot more about troubleshooting Linux systems. This book is filled with tips and techniques he has learned over years of managing mission critical systems.

Related