6

I never need to see the owner and group for the files listed with ls -l (actually, ls -laF) and am wondering if there's a way to remove them from the output. So I want to change this:

lrwxr-xr-x  1 chuck  staff  45 Jul  2 23:29 directory@ -> /Users/chuck/Projects/directory

into this:

lrwxr-xr-x  1 45 Jul  2 23:29 directory@ -> /Users/chuck/Projects/directory

I'm using bash under OS X, but I would assume the answer would apply to any Unix-y OS, such as the Debian machine that runs my web server.

1
  • You can leave out the group by using -o instead of -l
    – greg-449
    Jul 3, 2014 at 7:35

1 Answer 1

5

This can be accomplished by using the the -g and -o options for ls. For example:

user@host:~ # ls -go
total 0
drwx------+ 35   1190 Jul  2 18:24 Desktop
drwx------+ 78   2652 Jun 29 16:21 Documents
drwx------+ 11    374 Jul  2 11:05 Downloads
drwx------@ 70   2380 Mar 27 11:22 Library
drwx------+  6    204 Jun  2 20:00 Movies
drwxr-xr-x+  8    272 Oct 21  2013 Music
drwx------+  6    204 Jul  2 10:58 Pictures
drwxr-xr-x+  6    204 Jul  5  2013 Public
drwxr-xr-x+  4    136 May 29 14:52 Sites

There are a good number of options available to modify the output of /bin/ls which can be found in the utility's man page. Learning to read man pages can take a little bit of practice (and this is certainly the case for the more esoteric and deeper components of the OS). I would consider ls' page a great starting point. It's about a approachable as they come. Type at the command prompt man ls and dip your toes in to the deep waters. It's not so cold.

2
  • I actually did read man ls, but misunderstood what I was reading. It says -g will display the group name and that -o will omit the group id. Honestly, I'm more confused about this particular man page, but I'm happy it works. :)
    – Chuck
    Jul 3, 2014 at 9:51
  • In the version from (GNU coreutils) 8.21 man ls resport -g like -l, but do not list owner and -o like -l, but do not list group information :-) System you go man that you find ;-)
    – Hastur
    Jul 3, 2014 at 10:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .