- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- 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
Forums
Discussions
Discussions
Forums
Discussions
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
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