LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 06-04-2004, 06:00 PM   #1
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Rep: Reputation: 30
simple search and replace accross files/direcotries


In Windbloz I used to easily do a search and replace accross numerous files/directories with a nice little utility, is there the same function in Linux?

I have a directory /home/ that I want to search and replace all the words "yahoo" with "google" for instance. How is that done on the command line?

I know there are scripting ways people can try to throw together, but is there a built in way (that is fairly easy to use)? If not I would prefer the former if nothing else...
 
Old 06-04-2004, 06:07 PM   #2
drigz
Member
 
Registered: Apr 2004
Distribution: Gentoo ~x86
Posts: 407

Rep: Reputation: 30
i know you said no scripts, but this is so simple and you dont really need to script as you can just type it in at console:
for fl in /home/username/*
do
mv $fl $fl.old
sed 's/FINDSTRING/REPLACESTRING/g' $fl.old > $fl
# rm -f $fl.old
# when uncommented, the above line erases original file.
done
and
for fl in /home/username/*/*
do
mv $fl $fl.old
sed 's/FINDSTRING/REPLACESTRING/g' $fl.old > $fl
# rm -f $fl.old
# when uncommented, the above line erases original file.
done
if you want to descend another level. continue..
 
Old 06-04-2004, 06:14 PM   #3
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480 N, 95.3690 W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 45
This thread should help

http://www.linuxquestions.org/questi...hreadid=189011
 
Old 06-04-2004, 08:30 PM   #4
podollb
Member
 
Registered: Oct 2003
Location: Grand Forks, ND
Distribution: Suse/Slackware/RH
Posts: 161

Original Poster
Rep: Reputation: 30
Yeah I already saw that before I posted.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
search/replace in many files allelopath Linux - General 1 08-02-2005 09:21 PM
Search and Replace a string1 with string2 in many files TroelsSmit Linux - Newbie 5 12-16-2004 01:04 PM
Search and Replace over multiple files The_Nerd Linux - Software 8 06-20-2004 06:59 AM
search for pattern in files and replace mizuki26 Linux - Newbie 3 01-04-2004 11:57 AM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 01:04 AM


All times are GMT -5. The time now is 07:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration