Thursday, February 10, 2011

*/ for directories

Want to do something to only the directories but not the files? Just use Bash parameter expansion: */ is "everything whose name ends with a /", eg directories.

For example:
#print all the directories
echo */
#also print all the directories (without -d it recurses)
ls -d */
#zip all the directories in target
zip myoutputfile.zip target/*/
Kinda cool.

1 comment:

farhan said...

thanks Simple but yet interesting and engaging.. Keep up the good work!
my friend's blog
source: www.wbupdates.com

Post a Comment