How do I select a field/column from the output of `ls -l`?
Try ls -l | awk '{print $7}'
.
awk
selects columns so it's perfect for this task.
Never parse ls. Use GNU find
. Or if portability isn't important, stat(1)
.
find . -maxdepth 1 -printf '%Td\n'
For reading data other than lists of filenames line-by-line and splitting into fields, see: BashFAQ/001
There are no methods to reliably read a newline-delimited list of filenames that make sense under most circumstances.