I have this script:
#!/bin/sh
du -s */ [^.]*/ | sort -n | while read a; do echo $a; done | sed -r 's/^ *([ 0-9]{3})([ 0-9]{3})([ 0-9]{3}) *(.*)\/$/\1 \2 \3 \4/'
but for some reason I get this error:
du: cannot access `[^.]*/': No such file or directory
What am I missing? I don’t know what’s wrong with my script.
Thanks
Bash doesn’t support regexp as file name patterns by default, only glob.
Usually, directories that start with
.are not included in*/. If you want to include the save ones, use.??*/(excludes.and..). It’s not perfect (misses.X/) but is good enough most of the time.[EDIT] You can enable a subset of regexp with
shopt -s extglob(kudos to fered for pointing that out).See Bash Extended Globbing for details.