- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Script to copy lines with certain string prese...
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
тАО07-20-2006 11:50 PM
тАО07-20-2006 11:50 PM
/u01/oracle/product/8.1.7/bin/oracle::::APPLICATIONS,abc09def
I need a script that will find all lines with 8.1.9 and copy that exact line right underneath the original line but replace with 8.1.7 with 9.2.0...so it looks like the following:
/u01/oracle/product/8.1.7/bin/oracle::::APPLICATIONS,abc09def
/u01/oracle/product/9.2.0/bin/oracle::::APPLICATIONS,abc09def
Thanks for the help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2006 12:02 AM
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2006 12:24 AM
тАО07-21-2006 12:24 AM
Re: Script to copy lines with certain string present
To be strictly safe in our matching, i *should* escape the dot character :-))
# perl -nle 'print;print if s%/8\.1\.7/%/9\.2\.0/%' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2006 12:34 AM
тАО07-21-2006 12:34 AM
Re: Script to copy lines with certain string present
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2006 12:39 AM
тАО07-21-2006 12:39 AM
Re: Script to copy lines with certain string present
to remove duplicate use
cat /tmp/test |sort |uniq
will give only one line
Chan
- Tags:
- Sort
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2006 12:39 AM
тАО07-21-2006 12:39 AM
Re: Script to copy lines with certain string present
awk '/8.1.7/ {print}' filename |
sed 's/8.1.7/9.2.0/g' |sort |sort -u
This is not so beautiful as with perl, but it looks much simpler 8))))
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2006 12:44 AM
тАО07-21-2006 12:44 AM
Re: Script to copy lines with certain string present
You don't need extra processes spawned (e.g. 'cat' into a pipe). Rather:
# sort -u file|perl -nle 'print;print if s%/8\.1\.7/%/9\.2\.0/%'
Regards!
...JRF...
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2006 12:53 AM
тАО07-21-2006 12:53 AM
Re: Script to copy lines with certain string present
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2006 12:59 AM
тАО07-21-2006 12:59 AM
Re: Script to copy lines with certain string present
You wrote, "but the duplicates happen after the perl ... so shouldn't the sort happen after the perl to get rid of the lines?"
Please show some input and the output you want. I'm confused by your question.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2006 01:19 AM
тАО07-21-2006 01:19 AM
Re: Script to copy lines with certain string present
Now, when I do the sort -u it sorts the whole file...is there a way to tell it to sort only on lines beginning with /u01 and leave the rest of the file entact?