On Sun, Jun 24, 2001 at 05:00:09PM +0200, Federico Di Gregorio wrote:
> N=10
> FILE=tuo_file/con/tutto/il/path
> GREPPATO="`head -$N $FILE | grep 'abcd'`"
> if [ "x$GREPPATO" != "x"] ; then
>    echo "Ha trovato quello che volevo..."
> fi

o anche:

  if head -$N $FILE | grep 'abcd' &> /dev/null; then
    echo "C'e'"
  else
    echo "Non c'e'"
  fi
 
Questo perche' grep restituisce come exit code 0 in caso di almeno un
match e 1 se nessuna riga del file fa match.

Ciao

-- 
Stefano "Zack" Zacchiroli <[EMAIL PROTECTED]> ICQ# 33538863
Home Page: http://www.students.cs.unibo.it/~zacchiro
Undergraduate student of Computer Science @ University of Bologna, Italy
                        - Information wants to be Open -

Attachment: pgpfiXe3TLfnk.pgp
Description: PGP signature

Rispondere a