- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: sed question
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
тАО03-10-2009 01:58 PM
тАО03-10-2009 01:58 PM
I want to add line y after line x in httpd.conf file but struggling with it...
line x #CustomLog logs/localhost/access_log combined
line y CustomLog "|/bin/cat - >> /apache/logs/localhost/access_log" combined
Can you suggest a sed one liner for this. Mine doesnt work and gives wierd behaviour -
sed '=#CustomLog logs\/localhost\/access_log combined= a\CustomLog \"\|\/bin\/cat \- \>\> \/apache\/logs\/localhost\/access_log\" combined' httpd.conf >> httpd.conf.2
Thanks,
Allanm
Solved! Go to Solution.
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 02:20 PM
тАО03-10-2009 02:20 PM
Re: sed question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 02:30 PM
тАО03-10-2009 02:30 PM
Re: sed question
if this is a one-timer, use vi.
If this has to be done in a script:
...
{
print "/CustomLog logs\/localhost\/access_log combined/a"
print 'CustomLog "|/bin/cat - >> /apache/logs/localhost/access_log" combined'
print '.\nw'
} | ed - http.conf
...
mfG Peter
PS: untested
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 02:30 PM
тАО03-10-2009 02:30 PM
Re: sed question
sed -e '/^TargetString/a\
Appended string here'
Your string has so many quotes and slashes that it will take me a minute. If you do not need to match on the whole string that would certainly help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 02:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 03:00 PM
тАО03-10-2009 03:00 PM
Re: sed question
You could do:
# perl -ne 'if (/^#CustomLog/) {print;print qq(INSERT_ > "SOME" < _LINE\n)} else {print}' file
...Notice that the line to be inserted actually looks like:
INSERT_ > "SOME" < _LINE
...that is, you are free to put any string you want in its place, thus, you want:
# perl -ne 'if (/^#CustomLog/) {print;print qq(CustomLog "|/bin/cat - >> /apache/logs/localhost/access_log" combined\n)} else {print}' file
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 05:09 PM
тАО03-10-2009 05:09 PM