- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: One Liner sed
Operating System - HP-UX
1753856
Members
7513
Online
108809
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО10-08-2010 06:11 AM
тАО10-08-2010 06:11 AM
One Liner sed
Hi
I've sed file which writes # at the start and ! at the end
s/^/#/
s/$/!/
This works fine.
But advise me how can convert this in to a sed oneliner instead of using the se file
Sagar
I've sed file which writes # at the start and ! at the end
s/^/#/
s/$/!/
This works fine.
But advise me how can convert this in to a sed oneliner instead of using the se file
Sagar
- Tags:
- sed
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2010 06:35 AM
тАО10-08-2010 06:35 AM
Re: One Liner sed
Well,... just put all edits on the command line, using -e to introduce each.
And if you had picked a character other then '!' if could be:
# sed -e s/^/#/ -e s/$/~/ tmp.tmp
The issue is that depending on the shell (I think) you will need to escape or otherwise hide the "!"
So try:
# sed -e s/^/#/ -e s/$/\!/ your-file
or
# sed -e s/^/#/ -e 's/$/!/' your-file
fwiw,
Hein
And if you had picked a character other then '!' if could be:
# sed -e s/^/#/ -e s/$/~/ tmp.tmp
The issue is that depending on the shell (I think) you will need to escape or otherwise hide the "!"
So try:
# sed -e s/^/#/ -e s/$/\!/ your-file
or
# sed -e s/^/#/ -e 's/$/!/' your-file
fwiw,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2010 11:11 AM
тАО10-08-2010 11:11 AM
Re: One Liner sed
>HeinThe issue is that depending on the shell (I think) you will need to escape or otherwise hide the "!"
Real shells don't treat "!" as special.
And it's probably a good idea to always use '' for sed expressions:
sed -e 's/^/#/' -e 's/$/!/' your-file
Real shells don't treat "!" as special.
And it's probably a good idea to always use '' for sed expressions:
sed -e 's/^/#/' -e 's/$/!/' your-file
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP