Operating Systems > Linux and UNIX

Grep/File Searching question

(1/3) > >>

LorKorub:
I have about 40 or so *.php files that I fucked up with table dimensions on.  I need to delete a single phrase (height=200px) from all of the files.  Is there a way to use grep or awk to do this?

flap:
this will find all the *.php files in the current directory and strip out that phrase with sed:

for i in `find ./ -name '*.php'`; do sed 's/height=200px//g' $i > tmp; mv tmp $i; done

[ October 03, 2002: Message edited by: flap ]

LorKorub:
Thanks for the help, but that didn't work.

My command prompt just turned into a '>'

flap:
did you definitely paste/type it correctly? and you are using bash i presume?

Calum:
so in general if i wanted to change a recurring line (two or three ocurrences in each file) to a different line, i should use find and pipe it to sed? or would i use a different program for replacing.

I will read the manpages for sed and find when i get home, but if there's another utility needed for this, what is it please?

thanks.

Actually i was going to ask this exact question last week.

LorKorub, i suggest reading the manpages since a big long command string may often not be exactly what you require,and anyway there are more than one way to do most things and one will suit your style better than the others.

edit - i just checked flap's post and noticed there is no pipe, so what is going on here, please?
sorry to be so dumb and sorry to hijack somebody's thread but i am trying to do the same thing...

[ October 03, 2002: Message edited by: Calum ]

Navigation

[0] Message Index

[#] Next page

Go to full version