Dear All,
I am new bee in SHELL Scripting. I am writing a small script to search a given pattern in a file, later i need to improvise this to any file in the directory in tcsh.
Here is the script:
echo "Enter search pattern and press <CR> to start search"
read pattern
foreach i ( `cat $1` )
if (grep "$pattern" $i)
echo "$1 file contains the given $pattern pattern."
end
OUTPUT:
Error:
n.sh: line 3: syntax error near unexpected token `('
n.sh: line 3: `foreach i ( `cat $1` ) '
Please suggest.
BR,
srs