learingperl01
MIS
Hello everyone,
wondering if someone could please help me with the following problem. In the code shown below currently I am just running a search for any files that match dc001.anything.log. and then each log file that it finds I printout everything after the forth line. What I am trying to do is instead of printing everything after the fourth line I would like to print everything after a regex match for a string. For example if I have a file like the one below, I would like to match on the last occurrence of 'CONNECTION' then print everything after that match. I am pretty new to shell scripting so I am not even sure if this can be done.
Based on the sample file above the script should yield the following results/output.
thanks for the the help in advance.
wondering if someone could please help me with the following problem. In the code shown below currently I am just running a search for any files that match dc001.anything.log. and then each log file that it finds I printout everything after the forth line. What I am trying to do is instead of printing everything after the fourth line I would like to print everything after a regex match for a string. For example if I have a file like the one below, I would like to match on the last occurrence of 'CONNECTION' then print everything after that match. I am pretty new to shell scripting so I am not even sure if this can be done.
Code:
#!/bin/sh
DIR=$1
cd ${DIR}
find . -name 'dc001\.*\.log' -print | \
while read log
do
tail +5 ${log} > ${log}.deleting
mv ${log}.deleting ${log}
done
SAMPLE FILE
CONNECTION
CONNECTION
RESET
CONNECTION
BLAH
BLAH
BLAH
IP ADDRESS
BLAH
Based on the sample file above the script should yield the following results/output.
Code:
BLAH
BLAH
BLAH
IP ADDRESS
BLAH
thanks for the the help in advance.