Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash if file exists



 Ben Eisenbraun wrote: 
> On Thu, Apr 03, 2008 at 06:55:36PM -0400, Derek Martin wrote: 
>> Which can be further simplified to: 
>> 
>> if ls *.zip >/dev/null 2>&1; then 
> 
> That's probably more elegant on some level than my $?.  Derek's test of the 
> ls exit status embedded in the if statement jogged my memory for another 
> method: 
> 
> ls *.zip > /dev/null 2>&1 && echo 'zips!' || echo 'zippo!' 
> 
> There ends up being a tradeoff between brevity and legibility at some 
> point, but I don't think we've hit it yet.  Anyone got a shorter one? 
> 
> :-) 
> 
> -b 


BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org