I want to (1)identify files in a directory that are under 64 bytes and (2)print out their names and size. The following one-liner does the job:
find . -size -64c -exec ls -lh {} \;|awk '{print $5, $9}'
This prints out a list of files, along with their size.
Can I easily extend this one-liner to also print out the total number of files found. In effect to pipe the file list into a wc -l command?
>Solution :
Can I easily extend this one-liner to also print out the total number
of files found.
Yes, by printing NR at the END block:
... | awk '{ print $5, $9 } END { print NR }'
You can also include a suffix:
... END { print "Total number of files found: " NR }'