November 9th, 2010, 04:15 PM
Need help passing input to a grep
I am new to unix. I have a very long grep that I need to use alot daily. Can someone help me get started so I can pass input for two variables into proper place in grep?
The grep I am using:
grep -e 11581989 -e 25423470 ~/ent.log | grep -v 11581989.1 | grep -v 25423470.1 | grep -v 25423470.2 | grep -v ,25423470, | grep -v Mulitple
The two highlighted numbers are the two numbers I need to input and be placed in the proper places of the grep.
November 10th, 2010, 04:27 AM
create a script and pass the 2 numbers as arguments
e.g. script mygrep.sh
Then run e.g.
grep -e $1 -e 25423470 ~/ent.log | egrep -v "11581989.1|$2.1|25423470.2|,25423470,|Mulitple"
./mygrep.sh 11581989 25423470
Last edited by pdreyer; November 10th, 2010 at 04:35 AM.