LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   AIX (https://www.linuxquestions.org/questions/aix-43/)
-   -   tail multiple files not working in AIX - Help (https://www.linuxquestions.org/questions/aix-43/tail-multiple-files-not-working-in-aix-help-187303/)

atmguy 05-29-2004 08:37 AM

tail multiple files not working in AIX - Help
 
A
tail -f file1.log file2.log file3.log | grep RCODE
AIX says it can process only one file at a time.
AIX version: AIX 4.3.3-11

It works on Linux, unix.
We are not allowed to install gcc to make Multitail work.
vanheusden.com/multitail/

Is there any workaround for this, a shell script(ksh) to tail and grep all the files into a single file in '/tmp' and then tail it perhaps?

jschiwal 05-29-2004 01:56 PM

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.

zorba4 05-30-2004 10:04 AM

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.

looseCannon 05-30-2004 09:00 PM

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.

http://swatch.sourceforge.net.

Also, I will be happy to provide a tar file with all the compiled perl modules included. All you have to do is untar them and it is ready to go.

crabboy 05-31-2004 10:22 PM

How about trying a named pipe?

Code:

PIPENAME="/tmp/mypipe"

mknod $PIPENAME p

tail -f file1.log > $PIPENAME
tail -f file2.log > $PIPENAME
tail -f file3.log > $PIPENAME

grep < $PIPENAME RCODE



All times are GMT -5. The time now is 06:50 PM.