I like to restrict the columns shown in ls -l
command, by eliminating the first 4 columns.
ls -lh
shows:
drwxr-sr-x 20 gamma alpha 4.0K May 22 13:18 Desktop
drwxr-sr-x 3 gamma alpha 22 Oct 6 2014 Eclipse
-rw-r--r-- 1 gamma alpha 28K Jul 11 2014 fire
drwxr-sr-x 5 gamma alpha 48 Mar 31 2014 lb_deployment
To eliminate the first four columns, I tried ls -lh | cut -d " " -f5-
. But it doesn't behave as desired:
4.0K May 22 13:18 Desktop
alpha 22 Oct 6 2014 Eclipse
alpha 28K Jul 11 2014 fire
alpha 48 Mar 31 2014 lb_deployment
I like it to look like this:
4.0K May 22 13:18 Desktop
22 Oct 6 2014 Eclipse
28K Jul 11 2014 fire
48 Mar 31 2014 lb_deployment
The reason that it does not behave as desired is that, in cut
I defined delimiter to be blank space (-d " "
), but since the number of links (second column of \ls -lh
) of the first file is a 2-digit number (20), ls -lh
adds another blank space to the link counter of the files with 1-digit link counter to adjust the columns positions. And this causes cut
to not behave as desired.
Any ideas on how to fix this?
-d
off completely? It's not working because it's treating each space as the start of a new field.-d
thecut
will default to fields separated by {tab}.