|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Find and Replace in Files
Hi there,
Can anybody tell me how I can do a find and replace in files. I'm running Red Hat Linux. I want to find say : width="100" and remove it from each file in the directory where it is found. If anybody can tell me this I will be mucho grateful! Thanks |
|
#2
|
|||
|
|||
|
Code:
cd /dir for i in *; do cat "$i" | sed -e "s/width=\"100\"//g" > /tmp/tmpfile && cat /tmp/tmpfile > "$i"; done ![]()
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
|
#3
|
|||
|
|||
|
thanks for that, works a treat!
I'm a PHP programmer and want to get to grips with shell scripting...where would be a good place to start? Thanks |
|
#4
|
|||
|
|||
|
I learned most from a linux book with a small chapter about shell scripting plus the bash manual for advanced features. After this, I got some years of experience now. Everyday there is a new feature to find that you didnŽt know yet about...
The bash manual is somewhere in /usr/doc or /usr/share/doc or /usr/local/share/doc or ... youŽll find it ![]() YouŽll need to learn about the many tools that come with the average unix installation. Their interaction makes the real power of scripting. Last edited by M.Hirsch : May 29th, 2003 at 03:06 PM. |
|
#5
|
|||
|
|||
|
Google for advanced bash scripting, read the first hit
![]()
__________________
PHP manual | MySQL manual | Apache docs | Linux Documentation Project | Free Software Foundation Smart Questions HOWTO | PHP security | PHP FAQ | Posting HOWTO Wikipedia | English dictionary | Google | News | RFCs Thus Spoke Zarathustra | A Skeptic's Guide to Christianity | Project Gutenberg | Skeptic's Annotated Bible ParEcon | Marxists Internet Archive | The Memory Hole | Landover Baptist | DHMO Research Universal Declaration of Human Rights | UN Charter | Geneva Conventions Sinfest | Chopping Block | Filthy Lies | Bob the Angry Flower | How to Shoot Yourself In the Foot |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > Linux Help > Find and Replace in Files |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|