#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0

    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.

    Please help!!!

    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2007
    Posts
    168
    Rep Power
    7
    create a script and pass the 2 numbers as arguments

    e.g. script mygrep.sh
    Code:
    grep -e $1 -e 25423470 ~/ent.log | egrep -v "11581989.1|$2.1|25423470.2|,25423470,|Mulitple"
    Then run e.g.
    Code:
    ./mygrep.sh 11581989 25423470
    Last edited by pdreyer; November 10th, 2010 at 03:35 AM.

IMN logo majestic logo threadwatch logo seochat tools logo