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

Avatar
Benjamin Cane
Principal Engineer, Vice President

Principal Engineer focused on building cloud-native software solutions for financial platforms. Benjamin uses both his systems and software knowledge to build end-to-end platforms. Platforms purpose built for performance, and resiliency.

Next
Previous

Related