coolcommands.com - the search engine for unix sysadmins :: unix commands and scripts
Sunday May 27, 2012


 Home
 Search
 Advanced Search
 Category Search
 Affiliates
 Acknowledgements
 Cool Links

Username

Password

Remember me
Forgot your password?
Create an account

Who's Online
We have 38 guests online

Newest Member

advaxavardimb

Hit Counter
9134402 Visitors

cool Statistics
coolcommands:1330
Categories:83
Total queries:595502
Members:16439





Advanced Search coolcommands.com
Search Keyword:   Help
Exact match Match any (part of) word Full text search


coolcommand

one-liner to do a search and replace in a file
Description

Here is a quick one-liner which performs a search and replace of a regular expression in the same file where it finds the match. It is a combination of the find command and perl:

Example to do a search and replace of first occurance of match in the file site.conf:

# find . -name "site.conf" -exec perl -i -p -e "s/csc2.tar.gz/csc3.tar.gz/" {} \;

Example to do a search and replace of all matches in the file site.conf:

# find . -name "site.conf" -exec perl -i -p -e "s/csc2.tar.gz/csc3.tar.gz/g" {} \;

Example to do a search and replace for any files which end with a .pl extension:

# find . -name "*.pl" -exec perl -i -p -e "s/old_string/new_string/g" {} \;
Example

find . -name "*.pl" -exec perl -i -p -e "s/old_string/new_string/g" {} \;

Return to search results

Random coolcommands

coolcommand: how to get the date and time from a remote unix server
Example: telnet hostname 13
[show me the details]
coolcommand: metareplace - how to re-enable a disk of a mirror in Solaris Volume Manager
Example: metareplace -e d0 c1t1d0s2
[show me the details]
coolcommand: how to verify a SSL secured website by command line using openssl
Example: openssl s_client -connect www.example.com:443
[show me the details]
coolcommand: awk - oneliner to kill all current user specified processes if different from current time
Example: ps -ef | grep your_process | grep `whoami` | grep -v grep | awk 'BEGIN { {"date" | getline date ; split(date,d," "); t = d[4]} substr(t,1,7) != substr($5,1,7) {system ("kill " $2 )}'
[show me the details]

coolcommands.com - the search engine for UNIX sysadmins :: unix commands and scripts



FREE
myPMS

Password
Management
System

by

LVOware.com




Top 5 Submitters

lvo1152
audet37
kah00na32
Mariom24
lebjf00014

Top 5 Searches

Category Solaris49379
Category AIX46267
Category General UNIX43934
solaris22927
aix22116

Terms of Use
Privacy
Contact


 
coolcommands.com © 2012. All Right Reserved.
Programming by PRATTICO Consulting . Hosting by Apricusum