AIXThis forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
You could loop through every file argument and run tail on that file, piping through grep. You may want to use sed to precede each line with the filename and a colon. However if you weren't particular about how many lines at the bottom of the files were read, you could fgrep first, and tail to limit the number of matches. Then the filename would precede the match, thanks to fgrep.
I would try it that way :
I would write down a script like that :
#startup
rm /tmp/logfile.txt
for i in file1.log file2.log file3.log
do
tail -100f $i |grep RCODE >>/tmp/logfile.txt 2>&1 &
done
tail -100f /tmp/logfile.txt
# end script
I didn't even try it, but I think that my script should work.
Maybe you are going about this the hard way. Look at a free utility I recently managed to get installed on our AIX 5.x servers -- Swatch. It examines or tails, which ever mode you would like, files and will perform actions, print lines, email people, or do almost anything you want upon finding a match to whatever criteria you define.
Very nice. Very handy. I use it on a regular basis for going through massive log files.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.