You are not logged in.
Pages: 1
Hi,
I would like to write up a command (this is the default version):
ls -o -h --color=auto --group-directories-first
that turns default output:
total 60K
drwxr-xr-x 3 karabaja4 4.0K Dec 27 22:06 Downloads
drwxr-xr-x 6 karabaja4 4.0K Dec 24 11:42 projects
drwxr-xr-x 3 karabaja4 4.0K Dec 4 22:30 scripts
drwxr-xr-x 2 karabaja4 4.0K Dec 21 00:43 shared
drwxr-xr-x 2 karabaja4 20K Dec 12 00:15 shots
drwxr-xr-x 2 karabaja4 4.0K Oct 28 00:50 vmshared
drwxr-xr-x 3 karabaja4 4.0K Oct 19 14:29 vmware
drwxr-xr-x 3 karabaja4 12K Dec 24 16:29 wallpapers
into this
total 60K
Downloads 3 karabaja4 4.0K Dec 27 22:06 drwxr-xr-x
projects 6 karabaja4 4.0K Dec 24 11:42 drwxr-xr-x
scripts 3 karabaja4 4.0K Dec 4 22:30 drwxr-xr-x
shared 2 karabaja4 4.0K Dec 21 00:43 drwxr-xr-x
shots 2 karabaja4 20K Dec 12 00:15 drwxr-xr-x
vmshared 2 karabaja4 4.0K Oct 28 00:50 drwxr-xr-x
vmware 3 karabaja4 4.0K Oct 19 14:29 drwxr-xr-x
wallpapers 3 karabaja4 12K Dec 24 16:29 drwxr-xr-x
is it possible? I know very little sed, and this look troublesome because of tabs and different string sizes...
Last edited by karabaja4 (2010-12-27 22:48:06)
Offline
Then you should add a little awk, which is perfect when dealing with rows. Google might give you more information, try the search term "awk sort rows".
Offline
ls -o -h --color=auto --group-directories-first | awk '{if (NF == 2) print; else print sprintf("%-20s",$8),$2,$3,$4,$5,$6,$7,$1;}'
Specifying column widths need more love
Last edited by skunktrader (2010-12-27 23:07:08)
Offline
Here's a way:
ls -o -h --color=auto --group-directories-first | awk -F " " '{ print $8" "$2" "$3" "$4" "$5" "$6" "$7" "$1}' | column -t
Last edited by Ashren (2010-12-27 23:10:32)
Offline
LOL, 30 seconds apart Thanks!
Last edited by karabaja4 (2010-12-27 23:22:42)
Offline
Following up on falconindy's point: http://mywiki.wooledge.org/ParsingLs
Offline
Pages: 1