- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- PERL one-liner help needed (text search and replac...
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
тАО10-11-2006 05:33 AM
тАО10-11-2006 05:33 AM
All I want from this one liner is to replace a portion of a line in a given file. To be more specific, I need to disable the prm daemon on 50+ servers. To do this, I need to change the the line
PRM_RMTCONF=1
to
PRM_RMTCONF=0
So, what I am expecting from this one-liner is to look for the line, containing PRM_RMTCONF string and replce the value after the "=" to 0 (zero) regardless if it is 1 or 0 in the file /etc/rc/config.d/prm
It needs to be a one-liner because I want to launch it from a trusted management server via ssh and run it in a command line using a non-interactive session.
I know perl is created situations like this but I do not know how to attack this problem.
Help is greatly appreciated.
UNIX because I majored in cryptology...
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2006 05:43 AM
тАО10-11-2006 05:43 AM
Solution# perl -pi.old e 's/PRM_RMTCONF=\d\b/PRM_RMTCONF=0/' file
...This will substitute PRM_RMTCONF=
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2006 05:48 AM
тАО10-11-2006 05:48 AM
Re: PERL one-liner help needed (text search and replace)
perl -p -i -e 's/PRM_RMTCONF=1/PRM_RMTCONF=0/' myfile
This will modify "myfile" in place.
If you like you can add an argment to the -i switch:
perl -p -i.old -e 's/PRM_RMTCONF=1/PRM_RMTCONF=0/' myfile
and this has the effect of making a backup file myfile.old while the modified file, myfile, is rewritten.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2006 05:50 AM
тАО10-11-2006 05:50 AM
Re: PERL one-liner help needed (text search and replace)
Ooops! I dropped the "-" in fron of the "-p" switch:
# perl -pi.old -e 's/PRM_RMTCONF=\d\b/PRM_RMTCONF=0/' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2006 05:55 AM
тАО10-11-2006 05:55 AM
Re: PERL one-liner help needed (text search and replace)
# ex -s +"/^PRM_RMTCONF=/s/[0-9]*$/0/ | wq" /etc/rc.config.d/prm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2006 05:57 AM
тАО10-11-2006 05:57 AM
Re: PERL one-liner help needed (text search and replace)
UNIX because I majored in cryptology...