<div>[sean@sergeant:~]$ mkdir /tmp/nothing</div><div>[sean@sergeant:~]$ ls /tmp/nothing | while read A; do echo $A; done</div><div>[sean@sergeant:~]$</div><div><br></div><div>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.</div>
<div><br></div><div>Sean</div><div><br></div><br><div class="gmail_quote">On Tue, Jul 6, 2010 at 11:07 PM, Adam Thompson <span dir="ltr"><<a href="mailto:athompso@athompso.net">athompso@athompso.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I can't find what I'm looking for in the bash(1) manpage, hoping there's an<br>
easy answer...<br>
<br>
I want to use a construct like<br>
for i in ~/path/*; do something $i && rm $i; done<br>
<br>
which works great as long as there are files in ~/path/. However, when the<br>
directory is empty, I get:<br>
rm: cannot remove `/home/athompso/path/*': No such file or directory<br>
<br>
which isn't quite what I want. The quick fix in this case is to use<br>
for i in ~/path/*; do [ -f $i ] && something $i && rm $i; done<br>
<br>
but once again, that strikes me as inelegant and I can't remember OR find<br>
the better way to do it.<br>
<br>
Anyone?<br>
<br>
Thanks,<br>
-Adam<br>
<br>
<br>
_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br>
<a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Sean Walberg <<a href="mailto:sean@ertw.com">sean@ertw.com</a>> <a href="http://ertw.com/">http://ertw.com/</a><br>