Answer the question
In order to leave comments, you need to log in
How can I modify a bash function so that it executes correctly?
I wrote this function:
ldirs () { du -sh `ls -F "[email protected]" | grep "/$" | sed -e 's/\/$//'`; }
It lists the directory, looks only for subdirectories, and removes the slash in the output. This list of directories is then passed to the du -sh command.
Here's how it works:
$ ldirs
49M GNS3
129K PDF
72M programm
512 Videos
26M Documents
31M Downloads
13M Pictures
512 Music
512 Public
du: cannot access 'Work': No such file or directory
du: cannot access 'table': No such file or directory
1.0K Templates
The "Desktop" directory has a space in its name and each word is passed to the du command. Here's how to fix it?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question