[sean@sergeant:~]$ mkdir /tmp/nothing
[sean@sergeant:~]$ ls /tmp/nothing | while read A; do echo $A; done
[sean@sergeant:~]$
Also gets around nasty "argument list too long" messages and doesn't need you to remember arcane syntax. $A is quotable if you have spaces in the filename.
Sean
On Tue, Jul 6, 2010 at 11:07 PM, Adam Thompson
<athompso@athompso.net> wrote:
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
_______________________________________________
Roundtable mailing list
Roundtable@muug.mb.ca
http://www.muug.mb.ca/mailman/listinfo/roundtable
--
Sean Walberg <sean@ertw.com> http://ertw.com/