- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: A few sed questions
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
Discussions
Discussions
Forums
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
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-13-2008 02:46 PM
тАО08-13-2008 02:46 PM
Re: A few sed questions
> Dennis: You are missing the last line
Oops, yes, indeed! Add to the Perl script, too:
END{print $hold}'
# perl -nle 'if (/^ifeq/) {$hold=~s/install/NEWINSTALL/};print $hold if defined $hold;$hold=$_;END{print $hold}' file
# awk '{if (/^ifeq/) {sub("install","NEWINSTALL",hold)};if (NR>1) print hold};hold=$0};END{print hold}' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2008 02:59 PM
тАО08-13-2008 02:59 PM
Re: A few sed questions
both of you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2008 05:47 PM
тАО08-13-2008 05:47 PM
Re: A few sed questions
awk '
BEGIN {hold=$0}
{
if (/^ifeq/) {
sub("install","NEWINSTALL",hold)
}
print hold
hold=$0
}
END {print hold}' file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2008 06:46 AM
тАО08-14-2008 06:46 AM
Re: A few sed questions
> Dennis: You can also remove the check for NR > 1 by using BEGIN
Yes, and similarly, in my Perl code I could do:
# perl -ne 'INIT{$hold=<>};if (/^ifeq/) {$hold=~s/install/NEWINSTALL/};print $hold;$hold=$_;END{print $hold}' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2008 01:20 PM
тАО08-14-2008 01:20 PM
Re: A few sed questions
All right, here's a 'sed' script for you question of August 13:
# cat sedfilter
#!/usr/bin/sed -nf
h;N
/ifeq/ {H;s/install/NEWINSTALL/;p;}
/ifeq/!p
...run as:
# sedfilter file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2008 01:24 PM
тАО08-14-2008 01:24 PM
Re: A few sed questions
you are the script guru!
thanks a lot!
- « Previous
- Next »