4 ms·
I also do this, but the right way to parse the output of ls would really be to remember the syntax of stat(1). That way you avoid any trouble with spaces and ot
by a3_nm 12y ago
I also do this, but the right way to parse the output of ls would really be to remember the syntax of stat(1). That way you avoid any trouble with spaces and other such problems, and the command is not much longer:
$ find -print0 | xargs -0 stat -c "%U %G" | sort -u > user_group_list
- rootbear 12y agoNice! I though for a minute about using find, but I didn't know about those options to stat, and I just punted and used ls. I need to study the stat man page, apparently.
- babarock 12y agoYou kinda alluded to it, but I'm going to leave this here for reference. Here's a good explanation of why you should avoid parsing the output of `ls`: http://mywiki.wooledge.org/ParsingLs http://mywiki.wooledge.org/ParsingLs
- Erwin 12y agofind (or maybe just GNU find) has the equivalent of stat built in so you can even do: find -printf "%u %g\n"|sort|uniq -c