Hello,
I'm sure this is easy, but trying to figure this out: I see a similar example here: but can't get it to work: http://www.unix.com/shell-programming-and-scripting/44975-how-grep-variable-pattern.html
but I have a basic code structure like this:
my testfile2 is this:
I keep getting the following error no matter if I single quote or double quote. or use various brackets (which get me other errors)
I'm sure its simple and I'm overlooking something, but hoping someone can provide help or another document.
Thanks!
I'm sure this is easy, but trying to figure this out: I see a similar example here: but can't get it to work: http://www.unix.com/shell-programming-and-scripting/44975-how-grep-variable-pattern.html
but I have a basic code structure like this:
Code:
#!/bin/sh
pattern="hello|help"
while read line;do
egrep $pattern $line
done < testfile2
my testfile2 is this:
Code:
hi
hello
help
helo
h
I keep getting the following error no matter if I single quote or double quote. or use various brackets (which get me other errors)
Code:
egrep: hi: No such file or directory
egrep: hello: No such file or directory
egrep: help: No such file or directory
egrep: helo: No such file or directory
egrep: h: No such file or directory
I'm sure its simple and I'm overlooking something, but hoping someone can provide help or another document.
Thanks!