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

Benjamin Cane is Principal Engineer at American Express. He has more than 16 years of experience with roles in both systems and software engineering. He leverages both his systems and software skills to build end-to-end platforms. Platforms, purpose built for performance and resiliency. Benjamin is also the author of Red Hat Enterprise Linux - Troubleshooting Guide (2015, Packt Publishing), and he has published many popular articles on topics such as Linux, Docker, Python, Go and Performance Tuning. Thoughts and Opinions expressed in my articles are my own.

Next
Previous

Related