Command passed as argument to shell script

Posted by raj_arni on Stack Overflow See other posts from Stack Overflow or by raj_arni
Published on 2010-04-28T19:55:17Z Indexed on 2010/04/28 20:07 UTC
Read the original article Hit count: 244

Filed under:
|
|

Hi,

I want to pass a command to a shell script. This command is a grep command. While executing I am getting the following errors, please help:

myscript.sh "egrep 'ERROR|FATAL' \*20100428\*.log | grep -v aString"

myscript.sh is a simple script:

#!/bin/ksh

cd log

$1

the errors are:

egrep: can't open |
egrep: can't open grep
egrep: can't open -v
egrep: can't open aString

Error is because egrap sees |, grep, -v and aString as arguments.

© Stack Overflow or respective owner

Related posts about shell

Related posts about script