You may fetch the specific column in shell like:
ls -al | while read perm bsize user group size month day time file; do echo $day; done
or awk
as shown in @Corey answer, cut -c44-45
would also work after adjustment (since ls
has fixed columns) , or whatever else, however the main problem is that it won't be reliable and bulletproof (e.g. on Unix it may be $6
, not $7
, and it changes depending on arguments) making it not machine-friendly therefore it is not recommended to parse ls
command at all.
The best is to use different available commands such as find
or stat
, which can provide relevant options to format the output as you need. For example:
$ stat -c "%x %n" *
2016-04-10 04:53:07.000000000 +0100 001.txt
2016-04-10 05:08:42.000000000 +0100 7c1c.txt
To return column of only days of modifications, try this example:
stat -c "%x" * | while read ymd; do date --date="$ymd" "+%d"; done
It's worth to note that GNU stat
could have different options to BSD stat
, so it still won't be bulletproof across different operating systems.