1
if [[ -n  $(find $path  -name "$string*")  ]]
then
    <stuff>
else

<stuff>

fi

I want to reverse the above search like

 if [[ ! -n  $(find $path  -name "$string*")  ]]
then
    <stuff>
else

<stuff>

fi

But it wont allow this because here I am checking the find commands output any clue.thanks for help

user1874594
  • 2,277
  • 1
  • 25
  • 49

1 Answers1

2

You can reverse the search in find itself using:

find "$path" ! -name "$string*"

btw this is also valid:

[[ ! -n $(find $path -name "$string*") ]]

Or else you can use -z:

[[ -z $(find $path -name "$string*") ]]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • I used the # 2 one but the mistake I made was [[! and it did not recognize the !- Kept 'no space' for 'space' . But EVEN after that was fixed the equivalence is lost `[[ ! -n $(find $path -name "$string*") ]]` then echo "Yah" else echo "Nada"` . will always yield Yah . So ! n does not negate it at all and that is probably because we are checking for the number . `! -name` is fabulous TY anubhava. – user1874594 Jan 29 '14 at 19:31