I would like to read some constant values from the file and feed that as an input to the script, something like this.
./myscript urname
From above syntax, Im just using the Constant String from the input text, but script should perform actions on all the instances of variable string mapped to the constant from input text. Can some one provide me the method how to call this . Do i need to write any functions for this?
I would add an if statement to operate only on lines containing given parameter: while IFS="=" read $CONST $VARIABLE
do
if [ "$CONST" = "$1" ]
then
## do whatever with $CONST and $VARIABLE
fi
done < INPUT_FILE
Assume if the above Constant is Pattern of a File, & Variable is the instances of Files, where we want our script to search for the message. So how will this work, when.
The above syntax should read only the constant and redirect the script to search message in all the 3 instances of File. Just like give below.
./myscript message urname
But not like
./myscript message /root/dir/syslog/urname1 or /root/dir/syslog/urname2 or /root/dir/syslog/urname3
sorry, perl is not available in my environment to test this. Can you break that code in shell script. For your review, here is an samplescript uploaded, if you can capture the week points and correc the same. I feel there are many number of loop holes , but still unable to sort it out.