I'm working on a home work assignment. The question is:
Write an
awk
script to select all regular files (not directories or links) in/etc
ending with.conf
, sort the result by size from smallest to largest, count the number of files, and print out the number of files followed by the filenames and sizes in two columns. Include a header row for the filenames and sizes. Paste both your script and its output in the answer area.
I'm really struggling trying to get this to work through using awk. Here's what I came up with.
ls -lrS /etc/*.conf |wc –l
will return the number 33
which is the number of files .conf
files in the directory.
ls -lrS /etc/*.conf |awk '{print "File_Size"": " $5 " ""File_Name and Size"": " $9}'
this will make 2 columns with the name and size of the .conf
file in the directory.
It works, but I don't think it is what he's looking for. I'm having an AWKful time.