Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:12 AM
12-05-2003 05:12 AM
I'm trying to use the following command:
tail -f log.txt | grep sql >> log2.txt
but the log2.txt file is aways empty, even if a line containing "sql" is stored in log.txt.
Can you help me? Is there other way to do that?
tks.
Roberto
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:14 AM
12-05-2003 05:14 AM
Re: tail -f
What I think you really want to do is:
tail log.txt |grep sql >> log2.txt
The -f option is the follow option.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:16 AM
12-05-2003 05:16 AM
Re: tail -f
What does
cat log.txt | grep sql >> log2.txt
give you?
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:16 AM
12-05-2003 05:16 AM
Re: tail -f
tail log.txt |grep sql >>log2.txt
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:18 AM
12-05-2003 05:18 AM
Re: tail -f
tail -n 10 log.txt |grep sql >> log2.txt
will do the last tem lines.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:19 AM
12-05-2003 05:19 AM
Re: tail -f
What i want is to monitor the file log.txt, and as soon as a line with "sql" is appended, the file "log2.txt" is appended too. In other words, the file "log2.txt" is a online filter of the "log.txt".
Roberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:19 AM
12-05-2003 05:19 AM
Re: tail -f
# cat log.txt | grep sql >> log2.txt
tail command without a line option will list only the last 10 lines, but can increase that number with:
# tail -20 or tail -50 etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:21 AM
12-05-2003 05:21 AM
Re: tail -f
if you setup a pipe command like you do, output of the grep will not immediately go to log2.txt. It stays in a buffer until enough is ready for output or the command responsible for the output ends and thereby a flush occurs. You should have immediately the text in the outfile, when you quit the command.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:21 AM
12-05-2003 05:21 AM
Re: tail -f
In that case, I think Brian's suggestion is more what you need.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:22 AM
12-05-2003 05:22 AM
Re: tail -f
I do the same thing with one of our logs and the lines I provided should handle that for you.
-Bryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:24 AM
12-05-2003 05:24 AM
Re: tail -f
while true
do
tail -n 1 log.txt | grep sql >> log2.txt
done
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:28 AM
12-05-2003 05:28 AM
Re: tail -f
create a file called checksql containing
----------------cut--------------
#!/bin/sh
cat log.txt | grep sql >> log2.txt
sleep 60
exec checksql
----------------cut-----------------
This will pick up all instances of sql and write it out to your log file, sleep for 60 seconds, and then rerun itself.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:37 AM
12-05-2003 05:37 AM
Re: tail -f
Your solutions would repeat the past occurrences.
Bryan,
I don't know why, but your solution did not work properly.
Roberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:50 AM
12-05-2003 05:50 AM
Re: tail -f
try this:
#!/bin/ksh
LCOUNT=`wc -l log.txt|awk '{print $1}'`
while true
do
LCOUNT2=`wc -l log.txt|awk '{print $1}'`
if test ${LCOUNT} -eq ${LCOUNT2}
then
sleep 5
else
LINENUM=`expr ${LCOUNT2} - ${LCOUNT}`
tail -n${LINENUM} log.txt | grep sql >> log2.txt
LCOUNT=${LCOUNT2}
sleep 5
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:51 AM
12-05-2003 05:51 AM
Re: tail -f
When a line with sql is found in log.txt, then that entire line is appended to log2.txt? Is that correct?
If so, I am not sure why you had problems with my solution. I use it to tail our backup log every night. I just tested it again and as soon as log.txt is updated with a line with sql it is written to log2.txt.
What did you get when you tried it?
-Bryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:54 AM
12-05-2003 05:54 AM
Re: tail -f
I think the problem was my "shell", now everything works fine!
You're 10!
tks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 05:55 AM
12-05-2003 05:55 AM
Re: tail -f
Good, glad it worked out!
Thanks,
-Bryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 09:18 PM
12-05-2003 09:18 PM
Re: tail -f
I just found out, that my solution wasnt as waterproof as I thought, but who cares. The solution of Bryan is simple and ingeniuos. I still marvel, why it works. I spent many hours to find something like that because I wanted to controll "interactively" an ftp, but the last line of the output never showed up in the log. So I will have to try this one.
be happy,
Michael