LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-18-2004, 03:27 AM   #1
zwyrbla
Member
 
Registered: Aug 2004
Location: MA
Distribution: Slack 10.1
Posts: 107

Rep: Reputation: 15
Using grep to change multiple files


OK heres the story i made and maintain my mother websites she has for selling puppycoats now when i originally made it i did it on wndows using frontpage 2003 using dynamic web templates. Now that im all converted to linux i need a way to change the header on every page. im assuming i ahve to use the grep command somehow but im kidna clueless as to what exactly i msut do. oh and i know i should be doing jsut a php include but her host doesnt support it very well and i could never get it to work right. any help would be great thanks.
 
Old 12-18-2004, 03:44 AM   #2
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
Simple

Code:
grep -v -E "code or text" /path/to/file > /path/to/new/file
Read man page of grep for more info. Hope this helps
 
Old 12-18-2004, 04:52 AM   #3
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
Probably something like this: WARNING Untested code below!

for file in *.html; do sed 's/Text I want to change/What I want to change it to/' $file >$file.tmp;mv $file.tmp $file

Last edited by /bin/bash; 12-18-2004 at 04:53 AM.
 
Old 12-21-2004, 12:43 AM   #4
zwyrbla
Member
 
Registered: Aug 2004
Location: MA
Distribution: Slack 10.1
Posts: 107

Original Poster
Rep: Reputation: 15
I dont know who to make either of thsoe work the grep command ony lets me do one file at a time and the sed command jsut keeps pushing the line down and when i close it off with a ; it gives me an error.
 
Old 01-11-2005, 03:44 AM   #5
kees-jan
Member
 
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
Ah... yes... That tends to happen with untested code. :-)

From the looks of it, that for loop needs a "done" at the end. I guess I'd recommend a good book on shell scripting to get you started. And maybe you should start out trying something simpler. ;-)

Groetjes,

Kees-Jan
 
Old 01-11-2005, 03:14 PM   #6
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
done
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep multiple strings GEEXTER Linux - General 7 12-06-2013 10:56 PM
grep for multiple patterns???? lucastic Linux - Software 4 08-06-2010 07:07 PM
multiline grep result > multiple variable? mikshaw Linux - Software 5 12-25-2003 11:13 PM
How can i change names of multiple files? phz Linux - General 5 11-15-2003 11:06 AM
How to filter files in files and files which are in a sub-directory with "grep"? Piero Linux - Newbie 9 08-29-2003 03:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:56 PM.

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
Open Source Consulting | Domain Registration