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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-18-2004, 02:27 AM
|
#1
|
Member
Registered: Aug 2004
Location: MA
Distribution: Slack 10.1
Posts: 107
Rep:
|
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.
|
|
|
12-18-2004, 02:44 AM
|
#2
|
Member
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379
Rep:
|
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
|
|
|
12-18-2004, 03:52 AM
|
#3
|
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802
Rep:
|
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 03:53 AM.
|
|
|
12-20-2004, 11:43 PM
|
#4
|
Member
Registered: Aug 2004
Location: MA
Distribution: Slack 10.1
Posts: 107
Original Poster
Rep:
|
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.
|
|
|
01-11-2005, 02:44 AM
|
#5
|
Member
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273
Rep:
|
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
|
|
|
01-11-2005, 02:14 PM
|
#6
|
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802
Rep:
|
done
|
|
|
All times are GMT -5. The time now is 05:33 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|