- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- 'tail -f' piped with sed
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
08-07-2008 06:02 AM
08-07-2008 06:02 AM
I'm trying to trim some log files for better clarity for the operator. Therefore the logfiles shall only be altered on-the-fly, meaning I should not change the amount of log messages which are writen into the file. But I shall change the amount and look of the log messages which are printed out.
So I come to the idea to make a "tail -f | sed -f sed_command.file" command, but this command always ignores the latest log message. When a newer log message comes in, the older message apears, but now the new message doesn't show up.
I think that this error comes from the fact, that "tail -f" does not output a newline until a new message comes in.
Is it possibel to show up all log messages wihtout delay?
Thanks for your help in advance!
Regards, Markus
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2008 06:10 AM
08-07-2008 06:10 AM
Re: 'tail -f' piped with sed
This is likely a buffer issue. If the messages (as you define "message") don't end in a newline ("\n") then they will be buffered until a newline flushes them.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2008 06:16 AM
08-07-2008 06:16 AM
Re: 'tail -f' piped with sed
yes I already thought about that.
Do you see a way to "manually" send a newline or do a flush to the sed buffer?
What would you recommend to make it possible?
Thanks a lot!
Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2008 06:23 AM
08-07-2008 06:23 AM
Re: 'tail -f' piped with sed
OK, I can reproduce what you are seeing with 'sed'. If I use Perl I can defeat your problem. Post your 'sed' script if you like.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2008 06:31 AM
08-07-2008 06:31 AM
Re: 'tail -f' piped with sed
right now I'm using just a basic script for testing (attached)!
The comamnd I'm using:
"tail -f /clog/syslog/syslog.log | sed -f sed_command.file"
Thanks and Regards,
Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2008 06:47 AM
08-07-2008 06:47 AM
Solution# cat filter
#!/usr/bin/perl -p
s/(sapwas_main): Entering SGeSAP stop runtime steps .../SAP is beeing stopped .../;
s/(sapwas_main): Entering SGeSAP start runtime steps .../SAP is being started .../;
s/(sapwas_main): Leaving SGeSAP start runtime steps/SAP was successfully started/;
s/(sapwas_main): Leaving SGeSAP stop runtime steps/SAP was successfully stopped/;
s/ [A-Z][a-z][a-z] [1-3 ][0-9] [0-9][0-9]\:[0-9][0-9]\:[0-9][0-9] - Node \"s96hph0[1-4]\"://;
...run as you would expect:
# tail -f file | ./filter
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2008 06:58 AM
08-14-2008 06:58 AM
Re: 'tail -f' piped with sed
If you wish to continue to use 'sed', the GNU version offers the '-u' switch --- exactly what you need when handling input from something like 'tail -f'.
Regards!
...JRF...