- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- need sed help
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
12-09-2005 12:58 AM
12-09-2005 12:58 AM
need sed help
Can you help me to give me the sed right command to do this.
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2005 01:03 AM
12-09-2005 01:03 AM
Re: need sed help
By example:
# sed -ne '1,/localhost/d;p' /etc/hosts
Change /localhost/ to the pattern you want to match, and (obviously) substitute your file name for '/etc/hosts'.
Regards!
..JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2005 01:10 AM
12-09-2005 01:10 AM
Re: need sed help
sed -n '1,/XXXX/!p' filename
Regards,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2005 01:45 AM
12-09-2005 01:45 AM
Re: need sed help
it works fine.
But how can i do if the string "localhost" is a variable. That is declared as $localhost
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2005 02:03 AM
12-09-2005 02:03 AM
Re: need sed help
OK, do this:
# pat=localhost;sed -ne "1,/$pat/!p" /etc/hosts
Note the use of the double quote marks.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2005 05:15 AM
12-09-2005 05:15 AM
Re: need sed help
It works fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2005 08:20 PM
12-11-2005 08:20 PM
Re: need sed help
just a note: the command
sed -ne "1,/$pat/!p" /etc/hosts
runs fine but doens't remove the entry in the /etc/hosts file. It simply show at the screen the result.
To remove them to have to use:
sed -ne "1,/$pat/!p" /etc/hosts>tt
mv tt /etc/hosts
Rgds,
Art