Unexpected result from grep

From: Dan (daniel.j.botz_at_cummins.com)
Date: 12/11/03


Date: 11 Dec 2003 08:13:13 -0800

Hello,

I can't seem to figure out why this isn't working. I'm running it on
Tru64 V5.1A with patch kit 5. I'm probably missing something obvious.
 :-(

Here is my script:
/tmp # cat search
#!/usr/bin/ksh
set -x

typeset -r COMMAND='/sbin/grep'
typeset -r EXPRESSION="${1}"
typeset -r CHECK_FILE="${2}"
typeset RESULT=''

RESULT="$(${COMMAND} -E \'${EXPRESSION}\' ${CHECK_FILE} 2>/dev/null)"

print "RESULT: ${RESULT}"

Here is the test file:
/tmp # cat afile
rsh

Here is what happens when I run the script:
/tmp # search rsh afile
+ typeset -r COMMAND=/sbin/grep
+ typeset -r EXPRESSION=rsh
+ typeset -r CHECK_FILE=afile
+ typeset RESULT=
+ + /sbin/grep -E 'rsh' afile
+ 2> /dev/null
RESULT=
+ print RESULT:
RESULT:

Yet if I run the command at the command line, I get this:
/tmp # /sbin/grep -E 'rsh' afile
rsh

Thanks for your help!
Dan



Relevant Pages

  • Unexpected result from grep
    ... typeset -r EXPRESSION="$" ... /tmp # search rsh afile ... Yet if I run the command at the command line, ...
    (comp.unix.shell)
  • Re: zsh array assignment
    ... can provide some assistance ... I'd like to put the output of the jhead command (an image EXIF tag ...
    (comp.unix.shell)
  • Re: colon
    ... typeset -u DELETE='' ... ensures that the last command does not leave a non-zero exit code. ... return status of the command is 'success'. ... written the ';;' terminator on a line without any colon. ...
    (comp.unix.shell)
  • Re: Where are Global Aliases?
    ... command = ' command' ... functions = 'typeset -f' ... history = 'fc -l' ... I know for indivual users i can audit .env file and set my own alias ...
    (comp.unix.programmer)
  • Re: colon
    ... ensures that the last command does not leave a non-zero exit code. ... The "typeset" builtin ... There is another problem with the above code: The quotes ...
    (comp.unix.shell)