From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,f7f68e18cfb8d31b X-Google-Attributes: gidfa528,public X-Google-Thread: 1012a6,f7f68e18cfb8d31b X-Google-Attributes: gid1012a6,public X-Google-ArrivalTime: 2003-12-11 08:43:31 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!ash.uu.net!news.fore.com!not-for-mail From: Jens Schweikhardt Newsgroups: comp.unix.shell,comp.unix.tru64 Subject: Re: Unexpected result from grep Date: 11 Dec 2003 16:32:50 GMT Organization: Marconi Message-ID: References: NNTP-Posting-Host: 172.28.39.232 X-Trace: newsfeed.pit.comms.marconi.com 1071160370 20923 172.28.39.232 (11 Dec 2003 16:32:50 GMT) X-Complaints-To: usenet@fore.com NNTP-Posting-Date: 11 Dec 2003 16:32:50 GMT Xref: archiver1.google.com comp.unix.shell:3317 comp.unix.tru64:11026 In comp.unix.shell Dan wrote: # 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)" For EXPRESSION=foo, this will grep for 'foo', *including* the single quotes. You need to eval the string to have the single quotes be interpreted. RESULT="$(eval ${COMMAND} -E \'${EXPRESSION}\' ${CHECK_FILE} 2>/dev/null)" Should do the trick. Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped)