- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script to remove line
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
06-25-2008 12:42 AM
06-25-2008 12:42 AM
script to remove line
#vi event_log
aa
testing error
bb
cc
testing error
dd
testing error
ee
ff
gg
after update , it should be changed to
aa
bb
cc
dd
ee
ff
gg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 12:51 AM
06-25-2008 12:51 AM
Re: script to remove line
sed '/^testing error/ d' event_log
you can redirect the output to another file.
Kenan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 12:55 AM
06-25-2008 12:55 AM
Re: script to remove line
HTH..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 12:57 AM
06-25-2008 12:57 AM
Re: script to remove line
You can create a script containing following lines and put that in cron.
#!/usr/bin/sh
cat event_log |grep -v testing >event_log.new
Thanks
Davis Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 12:59 AM
06-25-2008 12:59 AM
Re: script to remove line
the command is work, but if I want the script run frenquently ( eg. every 1 sec ) , what can i do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 01:00 AM
06-25-2008 01:00 AM
Re: script to remove line
>I have assigned points to 1 of 116 responses to my questions.
A.Clay and SEP get very angry for these cases :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 01:08 AM
06-25-2008 01:08 AM
Re: script to remove line
http://hpux.cs.utah.edu/hppd/hpux/Gnu/sed-4.1.5/
you can use -i option to edit in place. So no need to redirect.
Kenan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 01:09 AM
06-25-2008 01:09 AM
Re: script to remove line
the script sed '/^testing error/ d' event_log will output the result to screen , if I want to directly update the event_log , what can i do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 01:30 AM
06-25-2008 01:30 AM
Re: script to remove line
Create a script like following and execute.
#!/usr/bin/sh
while ((1 > 0))
do
$cat event_log |grep -v testing >event_log.new
mv event_log.new event_log
sleep 5
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 02:35 AM
06-25-2008 02:35 AM
Re: script to remove line
Davis Paul's script can do that , but I think some data will be lost when the file is in movement , the sed method seems good , can advise how to use it to direct update the file ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 02:40 AM
06-25-2008 02:40 AM
Re: script to remove line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 02:50 AM
06-25-2008 02:50 AM
Re: script to remove line
Nah. All wrong.
What you want to do to solve this kind of problem is to use a PIPE aka FIFO
Instead od the providers writing (appending) to a real file, have them use a fifo. Now have a slave reading the fifo all the time and filter the data before going to the output.
For example.
A perl script: event_log_filter.pl
-------------
use IO::Handle;
open (OUT, ">>event_log_real") or die "no OUT";
OUT->autoflush(1);
while (1){
open (IN, "
print OUT unless /^testing error/;
}
print "are we done yet?\n";
}
------------
Now try in one window
# mkfifo event_log
# perl event_log_filter.p &
# tail -f event_log_real
And in an other window (or windows)
# cat > event_log
blah
blah blah
testing error
blah
Good luck!
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 09:41 AM
06-25-2008 09:41 AM
Re: script to remove line
I near panicked when I read this time requirement. You can't edit a file where other processes are trying to write to it. (Unless you are using fancy locking, etc.)
>can advise how to use it to direct update the file?
This will still lose data.
>Hein: All wrong.
>What you want to do to solve this kind of problem is to use a PIPE aka FIFO
Exactly. Or filter the stuff out just before you use it. (This wouldn't be helpful if the junk bloats the file too much.)
>Kenan: A.Clay and SEP get very angry for these cases :)
(It's called struck off. :-) (haeman's now up to 64!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2008 03:26 AM
06-26-2008 03:26 AM
Re: script to remove line
I think Hein van den Heuvel 's method is OK , but it is required to install module to the server , it is too complicate for me ,
I still think the command "sed '/^testing error/ d' event_log" is simple and meet my requirment , but I would like to ask how to direct update the file instead output to another file ?
please ignore the data lost issue .
thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2008 03:57 AM
06-26-2008 03:57 AM
Re: script to remove line
> I think Hein van den Heuvel's method is OK, but it is required to install module to the server, it is too complicate for me
That's not true. the 'IO::Handle' modules was released with Perl 5.00307. If, however, you would like to skip using it, for whatever reason, you can make the following change:
Instead of the line:
# OUT->autoflush(1);
...use these two statements:
# select OUT;
# $|++;
Regards!
...JRF...