1

The alias below works well in zsh when spaces in directory names are \ escaped, but bash doesn't handle them properly. What changes would be required to make them work with bash properly.

dum() {
  du -h --max-depth=1 $1  
}

zsh succeeds

 user@server: dum "Server Configuration"
32K     Server Configuration
 user@server: dum Server\ Configuration
32K     Server Configuration

bash fails

user@server:~$ dum "Server Configuration"
8.0K    Server/install_scripts
300K    Server
du: cannot access 'Configuration': No such file or directory
user@server:~$ dum Server\ Configuration/
8.0K    Server/install_scripts
300K    Server
du: cannot access 'Configuration/': No such file or directory      

How can the alias be written to make it work in bash?

0
4

(That's a function, not an alias)

Quote the variable:

dum() {
  du -h --max-depth=1 "$1"  
}

(That's BashPitfall #2 and #4.)

Not the answer you're looking for? Browse other questions tagged or ask your own question.