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-03-2009 12:02 AM
тАО03-03-2009 12:02 AM
For eg: below is my file
first line of text
second line of text
third line of text
fourth line of text
i want a output like this:
first line of text
second line of text New string added here
third line of text
fourth line of text
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2009 02:05 AM
тАО03-03-2009 02:05 AM
SolutionOne way is doing like this.
# sed -e "/second line/ a\test" temp
first line of text
second line of text
test
third line of text
fourth line of text
Another if you know specific row number.
# sed -e "2 a\test" temp
first line of text
second line of text
test
third line of text
fourth line of text
The above version is just search and add, make sure (if you're going to use that) that you have a exact match.
Otherwise you can end up like this:
# sed -e "/text/ a\test" temp
first line of text
test
second line of text
test
third line of text
test
fourth line of text
test
Best regards
Fredrik Eriksson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 10:05 AM
тАО03-09-2009 10:05 AM
Re: script
perl -ne 'if ($_ =~ /^third line of text/i) {$_ =~ s/[\r\n]+//; $_ .= " new string\n";} print "$_";' myfile > newfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 10:11 AM
тАО03-09-2009 10:11 AM
Re: script
sed -e "/second line of text/ s/.*/& New string added here/" test
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 11:21 PM
тАО03-09-2009 11:21 PM