Parts Catalog Accessories Catalog How To Articles Tech Forums
Call Pelican Parts at 888-280-7799
Shopping Cart Cart | Project List | Order Status | Help



Go Back   PeachParts Mercedes-Benz Forum > General Discussions > Off-Topic Discussion

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 01-24-2007, 11:18 PM
GottaDiesel's Avatar
Banned
 
Join Date: Sep 2003
Location: New Jersey
Posts: 1,564
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

Reply With Quote
  #2  
Old 01-24-2007, 11:28 PM
justinperkins's Avatar
I ♥ German Cars
 
Join Date: Sep 2006
Location: Austin
Posts: 1,312
Have you checked if you have shell access?
__________________
-justin

1987 300TD, 1987 300TD
2008 R32, 2000 Passat Wagon
Reply With Quote
  #3  
Old 01-24-2007, 11:41 PM
GottaDiesel's Avatar
Banned
 
Join Date: Sep 2003
Location: New Jersey
Posts: 1,564
I do... what'cha thinkin'?
Reply With Quote
  #4  
Old 01-24-2007, 11:43 PM
justinperkins's Avatar
I ♥ German Cars
 
Join Date: Sep 2006
Location: Austin
Posts: 1,312
Well I'm no shell guy, but couldn't you grep for the phrase?
__________________
-justin

1987 300TD, 1987 300TD
2008 R32, 2000 Passat Wagon
Reply With Quote
  #5  
Old 01-25-2007, 08:35 AM
GottaDiesel's Avatar
Banned
 
Join Date: Sep 2003
Location: New Jersey
Posts: 1,564
I dunno -- but I'm gonna google "grep" via unix and see what I learn. Thanks, Pete
Reply With Quote
  #6  
Old 01-25-2007, 10:07 AM
Dee8go's Avatar
Senor User
 
Join Date: Apr 2006
Location: The People's Republic of Arlington, VA
Posts: 7,193
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
Reply With Quote
  #7  
Old 01-25-2007, 10:07 AM
Dee8go's Avatar
Senor User
 
Join Date: Apr 2006
Location: The People's Republic of Arlington, VA
Posts: 7,193
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
Reply With Quote
  #8  
Old 01-25-2007, 10:23 AM
justinperkins's Avatar
I ♥ German Cars
 
Join Date: Sep 2006
Location: Austin
Posts: 1,312
Quote:
Originally Posted by Dee8go View Post
What in the hell is "grep?"
http://www.google.com/search?q=grep
__________________
-justin

1987 300TD, 1987 300TD
2008 R32, 2000 Passat Wagon
Reply With Quote
  #9  
Old 01-25-2007, 10:27 AM
Dee8go's Avatar
Senor User
 
Join Date: Apr 2006
Location: The People's Republic of Arlington, VA
Posts: 7,193
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
Reply With Quote
  #10  
Old 01-25-2007, 10:37 AM
justinperkins's Avatar
I ♥ German Cars
 
Join Date: Sep 2006
Location: Austin
Posts: 1,312
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
Reply With Quote
  #11  
Old 01-25-2007, 10:37 AM
justinperkins's Avatar
I ♥ German Cars
 
Join Date: Sep 2006
Location: Austin
Posts: 1,312
Quote:
Originally Posted by Dee8go View Post
Thanks, Justin. Now I have learned sumthin' new today and can go back to sleep.
It's wake up time, not sleepy time!
__________________
-justin

1987 300TD, 1987 300TD
2008 R32, 2000 Passat Wagon
Reply With Quote
  #12  
Old 01-25-2007, 10:38 AM
Dee8go's Avatar
Senor User
 
Join Date: Apr 2006
Location: The People's Republic of Arlington, VA
Posts: 7,193
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
Reply With Quote
  #13  
Old 01-25-2007, 10:38 AM
Registered User
 
Join Date: Oct 2005
Posts: 4,263
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.
Reply With Quote
  #14  
Old 01-25-2007, 10:41 AM
Registered User
 
Join Date: Oct 2005
Posts: 4,263
Quote:
Originally Posted by justinperkins View Post
find . -name '*.extension' | xargs grep 'your special phrase'
Makes pretty good sense. It will work as long as there are no filenames (including directory names) with embedded whitespace, e.g. "Program Files." This is a limitation of xargs.

To handle these, you'll need to use the -exec option to find, which makes things just a bit trickier.

Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:27 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0
Copyright 2024 Pelican Parts, LLC - Posts may be archived for display on the Peach Parts or Pelican Parts Website -    DMCA Registered Agent Contact Page