[RndTbl] bash expansion question
Adam Thompson
athompso at athompso.net
Tue Jul 6 23:07:35 CDT 2010
I can't find what I'm looking for in the bash(1) manpage, hoping there's an
easy answer...
I want to use a construct like
for i in ~/path/*; do something $i && rm $i; done
which works great as long as there are files in ~/path/. However, when the
directory is empty, I get:
rm: cannot remove `/home/athompso/path/*': No such file or directory
which isn't quite what I want. The quick fix in this case is to use
for i in ~/path/*; do [ -f $i ] && something $i && rm $i; done
but once again, that strikes me as inelegant and I can't remember OR find
the better way to do it.
Anyone?
Thanks,
-Adam
More information about the Roundtable
mailing list