- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sed question, tricky one
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-06-2005 07:36 AM
06-06-2005 07:36 AM
sed question, tricky one
sed -e '1,/${variable}/!d'
but it does not satisfy the condition when the ${variable} is part of the first line.
Could someone please comment and recommend a fix. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 08:14 AM
06-06-2005 08:14 AM
Re: sed question, tricky one
perl -n -e 'print if 1../abc/' yourfile
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 08:16 AM
06-06-2005 08:16 AM
Re: sed question, tricky one
perl -n -e "print if 1../${variable}/" yourfile
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 08:21 AM
06-06-2005 08:21 AM
Re: sed question, tricky one
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 08:31 AM
06-06-2005 08:31 AM
Re: sed question, tricky one
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 08:51 AM
06-06-2005 08:51 AM
Re: sed question, tricky one
There was a typo, the sed line should be:
sed -e '1,/'${variable}'/!d' filename
or
sed -e '1,/"${ckpoint}"/!d'
But here is what I don't understnad. The content of filename:
---start---
2005011211.zip
2004201004.zip
2005012004.zip
2005011950.zip
2005013102.zip
---end---
sed -e 1,/2005011211.zip/!d filename will return all the 5 lines which is rather strange.
sed -e /2005013102.zip/!d will only return
2004201004.zip
The perl -n -e 'print if 1../2005011211.zip/' will return 2005011211.zip
Is that a sed issue? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 05:08 PM
06-06-2005 05:08 PM
Re: sed question, tricky one
------test.log---------
2005011211.zip
2004201004.zip
2005012004.zip
2005011950.zip
2005013102.zip
Execution to print from 1st line to 2005011950.zip as,
# sed -n '{1,/2005011950.zip/p;}q' test.log
It will do it.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 05:09 PM
06-06-2005 05:09 PM
Re: sed question, tricky one
# sed -e '{1,/2005012004.zip/!d;}q' test.log for printing from 1 to 2005012004.zip pattern.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2005 01:38 PM
06-08-2005 01:38 PM
Re: sed question, tricky one
sed: -e expression #1, char 24: Extra characters after command
$ sed -e '{1,/2005012004.zip/!d;}' test.log
2005011211.zip
2004201004.zip
2005012004.zip
$ sed -e '{1,/200501121.zip/!d;}' test.log
2005011211.zip
2004201004.zip
2005012004.zip
2005011950.zip
2005013102.zip
That was not I was looking for. Thanks for trying. I'll go with the perl solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 08:31 PM
06-17-2005 08:31 PM
Re: sed question, tricky one
here is the portion of a output from man sed
Same as above but use shell or environment variables var1 and var2 in
search and replacement strings:
sed "s/$var1/$var2/" file1 >file1.out
or
sed 's/'$var1'/'$var2'/' file1 >file1.out
Multiple substitutions in a single command:
hope it sprays some light to your query...
Regards
Vinod K