|
Newest Member
|
|---|
| advaxavardimb | |
| cool Statistics |
| | coolcommands: | 1330 | | Categories: | 83 | | Total queries: | 595502 | | Members: | 16439 | |
|
|
|
 |
|
|
Advanced Search coolcommands.com
 |
Submitted by:
lvo   |
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
|  |  |  |  |
|
|
|
|
 |
|
|
|
Top 5 Submitters
|
|---|
| lvo | 1152 |
| audet | 37 |
| kah00na | 32 |
| Mariom | 24 |
| lebjf000 | 14 |
Top 5 Searches
|
| Category Solaris | 49379 |
| Category AIX | 46267 |
| Category General UNIX | 43934 |
| solaris | 22927 |
| aix | 22116 |
|
|
|
|