LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-29-2008, 08:54 AM   #1
Nortekman
LQ Newbie
 
Registered: Oct 2008
Posts: 9

Rep: Reputation: 0
Question from a Newbie - How to do mass changes?


Hello everyone, this is the the first time I do this, so be patient with me.

I have a paper to write about how to do "mass changes", but haven't found anything...............

This is the assignment:

SBC recently acquired AT&T and decided to change its name to AT&T because of the popularity of the brand name. They have thousands of web pages that need to be changed. Find tool(s) to change all occurrences of SBC to AT&T in all of the web pages.
The tools may be for Linux and/or Windows.
Submit relevant URL(s) to backup your strategy. Modifying individual files manually is NOT an acceptable solution.


If you know any tools, please post them

Thank you!!
 
Old 10-29-2008, 09:10 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Using 'sed' or 'awk' would probably be the best options. If you want to rename the files themselves use 'rename'.

With sed the usual format is:

Code:
sed 's|SBC|AT&T|g'
See here for more:
http://www.grymoire.com/Unix/Sed.html
 
Old 10-29-2008, 10:25 AM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 387Reputation: 387Reputation: 387Reputation: 387
I also think that sed would be the right tool. You can use -i to save the changes to the same file you are sed'ing, and embed it into a find sentence. For example, if you have all the files under /var/www/ you would do (previous backup, no need to say):

Code:
find /var/www -exec sed -e 's/SBC/AT&T/g' -i '{}' \;
Note that this will also change the ocurrences in htref's and the like, that means that you probably also want to run something like:

Code:
find /var/www -name '*SBC*' | while read file; do mv "$file" "${file/SBC/AT&T}"; done
Assuming you use bash, since ${var/str1/str2} is a bashism and will probably not work on any other shell.
 
Old 10-29-2008, 03:14 PM   #4
Nortekman
LQ Newbie
 
Registered: Oct 2008
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks a lot, you both saved my ass, that paper was due today at 1:00 p.m.
I guess my problem at finding it, was that he asked for "tools" and for me that means something you download, while sed and awk are commands
 
Old 10-29-2008, 04:14 PM   #5
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,125
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
rpl is a great tool for doing this kind of thing.
 
Old 10-29-2008, 04:32 PM   #6
normscherer
Member
 
Registered: Sep 2005
Location: Prescott, AZ
Distribution: Ubuntu Mint LTS 14 and 16
Posts: 44

Rep: Reputation: 15
Linux generally follows/inherits the Unix philosophy of small tools each of which does a task well but does not attempt to do tasks better done by another tool. Examples are sed, awk, grep, find, cmp, diff, .... the list is very long.
 
Old 10-29-2008, 04:34 PM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
So this was homework ... just remember that asking for help with it is kinda against forum rules. I suspected it was so I gave hints and links, but the mods may get angry if you do this too often...
 
  


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
a question about renaming files in mass! zeltak Linux - Software 1 05-24-2006 07:12 AM
newbie: usb mass storage, powershot a80 kinderbrunnen Linux - Hardware 3 02-21-2004 08:55 AM
Apache newbie question.. (very newbie question) tarballed Linux - Newbie 1 02-07-2003 09:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration