Re: grep
On 24 Jun 2001 16:27:21 +0200, Roberto Zanasi wrote:
> Vorrei scrivere uno script shell che funzioni in questo modo:
>
> se tra le prime N righe di un file di testo c'e' la stringa ABCD allora
> esegui un comando
>
> So che le prime N righe si estraggono con head e la ricerca si fa con
> grep, ma come faccio per dirgli "se grep riporta un risultato positivo
> allora..."?
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
--
Federico Di Gregorio
MIXAD LIVE Chief of Research & Technology fog@mixadlive.com
Debian GNU/Linux Developer & Italian Press Contact fog@debian.org
Those who do not study Lisp are doomed to reimplement it. Poorly.
-- from Karl M. Hegbloom .signature
Reply to:
- Follow-Ups:
- Re: grep
- From: Stefano Zacchiroli <zack@debian.org>
- References:
- grep
- From: "Roberto Zanasi" <roberto.zanasi@libero.it>