lundi 8 juin 2015

BASH: using grep after IF statment

i'm trying to send two arguments to .run file. $2 default should be 0.

if $2 arg = 1 then

grep -i a -1 --color -E $1 *.*

else

grep -i --color -E $1 *.*

, something like this

if [${2:-0} = 1] then
  grep -i a -1 --color -E $1 *.*
else
  grep -i --color -E $1 *.*
fi

but it didn't seem to work ? any ideas ?

thanks

Aucun commentaire:

Enregistrer un commentaire