How to limit output of ls to only show filename, date and size?
ls -l | awk '{print $5, $6, $7, $9}'
This will print the file size in bytes, month, date, and filename.
jin@encrypt /tmp/foo % ls -l
total 0
drwxr-xr-x 2 jin wheel 68 Oct 4 12:43 bar
drwxr-xr-x 2 jin wheel 68 Oct 4 12:43 baz
drwxr-xr-x 2 jin wheel 68 Oct 4 12:43 quux
jin@encrypt /tmp/foo % ls -l | awk '{print $5, $6, $7, $9}'
68 Oct 4 bar
68 Oct 4 baz
68 Oct 4 quux
Technically, it's not possible with ls
, but find
can do the same job with its -printf
switch:
find -maxdepth 1 -printf '%t %s %p\n'
you can always do:
$ ls -l
total 0
-rw-r--r-- 1 user staff 0 Oct 6 23:29 file1
-rw-r--r-- 1 user staff 0 Oct 6 23:29 file2
-rw-r--r-- 1 user staff 0 Oct 6 23:30 file3
-rw-r--r-- 1 user staff 0 Oct 6 23:30 file4
-rw-r--r-- 1 user staff 0 Oct 6 23:30 file5
-rw-r--r-- 1 user staff 0 Oct 6 23:30 file6
-rw-r--r-- 1 user staff 0 Oct 6 23:30 file7
cut
it to:
$ ls -l | cut -f 8-13 -d ' '
0 Oct 6 23:29 file1
0 Oct 6 23:29 file2
0 Oct 6 23:30 file3
0 Oct 6 23:30 file4
0 Oct 6 23:30 file5
0 Oct 6 23:30 file6
0 Oct 6 23:30 file7
$