[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Passing the results of GREP into a Bash Variable
From: |
Chet Ramey |
Subject: |
Re: Passing the results of GREP into a Bash Variable |
Date: |
Wed, 11 Jul 2001 11:26:55 -0400 |
> I am working on a script that requires the result of a grep to be
> piped or entered into a variable for an if, then, else check. Is that at
> all possible?
If you want the results that grep prints to the standard output, use
command substitution:
GREPOUT=$(grep ...)
If you want the exit status of grep, use $?:
grep ...
GREPSTAT=$?
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)
Chet Ramey, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/