Generating Reports with awk

Back in Chapter 6, we showed you how to edit delimited files with awk, which is cool because it lets you extract specific pieces of information, such as names and phone numbers, from delimited files. As shown in Code Listing 17.4, you can also use awk to generate reports. We start with the information from an ls -la command, and then use awk to generate a report about who owns what

Code Listing 17.4. Use awk to generate quick reports.
[ejr@hobbes /home]$  ls -la | awk '{print$9 " owned by "   $3 } END { print NR "Total Files" } ' owned by . owned by root .. owned by root admin owned by admin anyone owned by anyone asr owned by asr awr owned by awr bash owned by bash csh owned by csh deb owned by deb debray owned ...

Get Unix Third Edition: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.