Unix Shell - double negative

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > April 2004 > double negative





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author double negative
MarzBarzTM

2004-04-25, 9:33 am

I can use a IF statement responding when a file is empty with:

if [ ! - file1 ]; then action1 ;fi

But I need a specific action when 2 specific files are empty in the same
time then:

if [ ! -s file1 -a \(! -s file2 \) ]; then action2 ;fi

didn't worked and I tried a couple of variations without success. What
is the proper form?
joe@invalid.address

2004-04-25, 9:33 am

MarzBarzTM <marzbarztm@candy.uk> writes:

> I can use a IF statement responding when a file is empty with:
>
> if [ ! - file1 ]; then action1 ;fi
>
> But I need a specific action when 2 specific files are empty in the
> same time then:
>
> if [ ! -s file1 -a \(! -s file2 \) ]; then action2 ;fi
>
> didn't worked and I tried a couple of variations without success. What
> is the proper form?


if [ ! -s file1 -a ! -s file2 ];then action2;fi

See the test man page.

Joe
--
If people don't want to come out to the ballpark, nobody's going
to stop them.
- Yogi Berra
MarzBarzTM

2004-04-25, 10:34 am

joe@invalid.address wrote:

> MarzBarzTM <marzbarztm@candy.uk> writes:
>
>
>
>
> if [ ! -s file1 -a ! -s file2 ];then action2;fi
>
> See the test man page.
>
> Joe


You are right! Thank you!
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com