- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: replace $2 using sed
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
тАО04-06-2009 06:28 AM
тАО04-06-2009 06:28 AM
is it possible to change the value of $2 using sed?
ie
MGTSYS=myserver
sed -e "/^server/ s/$2/${MGTSYS}/" etc/ntp.conf
??
Thanks
Chris.
Solved! Go to Solution.
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 06:34 AM
тАО04-06-2009 06:34 AM
Re: replace $2 using sed
by $2 , you mean second column ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 06:38 AM
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 06:46 AM
тАО04-06-2009 06:46 AM
Re: replace $2 using sed
I suspect you mean:
# sed -e "s/\(server \)\(.*\)/\1${MGTSYS}/" /etc/ntp.conf
...as to change lines like:
server chris.xyz.com
to:
server lawrenzo.xyz.com
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 07:07 AM
тАО04-06-2009 07:07 AM
Re: replace $2 using sed
cat ntp.conf| sed "/^server/s/\(server\) \(.*\)/\1 ${MGTSYS}/"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 07:13 AM
тАО04-06-2009 07:13 AM
Re: replace $2 using sed
> P.R. if you really want sed :
The 'cat' is useless overhead. Sed is quite capable of reading a file from the command line. You only added a useless process and an additional read and write of the input file into a pipe!
...JRF...
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 07:20 AM
тАО04-06-2009 07:20 AM
Re: replace $2 using sed
yes of course cat is not mandatory .. it was just a way of do it ..
you are right , sed can do the job alone ..
pat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 07:28 AM
тАО04-06-2009 07:28 AM
Re: replace $2 using sed
Thanks all
Chris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 07:29 AM
тАО04-06-2009 07:29 AM