Monthly Archives: January 2012

Extending ls command

How to generate list of files and their size in bytes?

Comma Separated List (CSV)
$ ls -l | awk '{ print $5 "," $9 }' > list.csv

Tab Separated List (TSV)
$ ls -l | awk '{ print $5 "\t" $9 }' > list.tsv

$5 – Ordinal position for Size in bytes.
$9 – Name of the file.

Get a count of files/folders in the current directory
$ ls -l | wc -l