|
|
|
#1
|
||||
|
||||
Lookin' for a special FTP-Find/Replace Text Utility...
Anyone got a utility that will let me search multiple files/directories on a server for a certain phrase, and then replace it?
Pete |
#2
|
||||
|
||||
Have you checked if you have shell access?
__________________
-justin 1987 300TD, 1987 300TD 2008 R32, 2000 Passat Wagon |
#3
|
||||
|
||||
I do... what'cha thinkin'?
|
#4
|
||||
|
||||
Well I'm no shell guy, but couldn't you grep for the phrase?
__________________
-justin 1987 300TD, 1987 300TD 2008 R32, 2000 Passat Wagon |
#5
|
||||
|
||||
I dunno -- but I'm gonna google "grep" via unix and see what I learn. Thanks, Pete
|
#6
|
||||
|
||||
Well, just don't let me hear you gripe about it if grepin's no good. . .
__________________
" We have nothing to fear but the main stream media itself . . . ."- Adapted from Franklin D Roosevelt for the 21st century OBK #55 1998 Lincoln Continental - Sold Max 1984 300TD 285,000 miles - Sold The Dee8gonator 1987 560SEC 196,000 miles - Sold Orgasmatron - 2006 CLS500 90,000 miles 2002 C320 Wagon 122,000 miles 2016 AMG GTS 12,000 miles |
#7
|
||||
|
||||
What in the hell is "grep?"
__________________
" We have nothing to fear but the main stream media itself . . . ."- Adapted from Franklin D Roosevelt for the 21st century OBK #55 1998 Lincoln Continental - Sold Max 1984 300TD 285,000 miles - Sold The Dee8gonator 1987 560SEC 196,000 miles - Sold Orgasmatron - 2006 CLS500 90,000 miles 2002 C320 Wagon 122,000 miles 2016 AMG GTS 12,000 miles |
#8
|
||||
|
||||
__________________
-justin 1987 300TD, 1987 300TD 2008 R32, 2000 Passat Wagon |
#9
|
||||
|
||||
Thanks, Justin. Now I have learned sumthin' new today and can go back to sleep.
__________________
" We have nothing to fear but the main stream media itself . . . ."- Adapted from Franklin D Roosevelt for the 21st century OBK #55 1998 Lincoln Continental - Sold Max 1984 300TD 285,000 miles - Sold The Dee8gonator 1987 560SEC 196,000 miles - Sold Orgasmatron - 2006 CLS500 90,000 miles 2002 C320 Wagon 122,000 miles 2016 AMG GTS 12,000 miles |
#10
|
||||
|
||||
Ok, I asked somebody at work today and this is one way to do it:
so you've ssh'd in, and now you should change to the main directory you want to search on (the search will look in all subdirectories), then you can run something like this: find . -name '*.extension' | xargs grep 'your special phrase' The '.' means start the search in the current directory (it will look in all subdirectories automatically, this is called a recursive). The *.extension is to only look inside files that have that extension, so you don't end up searching through a lot of files you don't care about. The '|' is called pipe and it is used to pass the result of one command to another. In this case we're passing the results from the find to xargs, which will run each item given to it against the command specified (in this case 'grep'). Make sense?
__________________
-justin 1987 300TD, 1987 300TD 2008 R32, 2000 Passat Wagon |
#11
|
||||
|
||||
It's wake up time, not sleepy time!
__________________
-justin 1987 300TD, 1987 300TD 2008 R32, 2000 Passat Wagon |
#12
|
||||
|
||||
Whaaa . . . ?
__________________
" We have nothing to fear but the main stream media itself . . . ."- Adapted from Franklin D Roosevelt for the 21st century OBK #55 1998 Lincoln Continental - Sold Max 1984 300TD 285,000 miles - Sold The Dee8gonator 1987 560SEC 196,000 miles - Sold Orgasmatron - 2006 CLS500 90,000 miles 2002 C320 Wagon 122,000 miles 2016 AMG GTS 12,000 miles |
#13
|
|||
|
|||
Grep finds strings and prints them. If you want to do replacements, you will need awk or sed. Grep got its name from an editor command, "goto regular expression and print." Sed is short for "stream editor." I have no idea why "awk."
You'll also need "find," to iterate through the filesystem. |
#14
|
|||
|
|||
Quote:
To handle these, you'll need to use the -exec option to find, which makes things just a bit trickier. |
Bookmarks |
|
|