View previous topic :: View next topic |
Author |
Message |
oc666 Guru

Joined: 15 May 2006 Posts: 330 Location: Israel
|
Posted: Sat Apr 07, 2007 8:58 pm Post subject: replace text in files with console |
|
|
Hello
I've 100 php files. I want to replace the html tag with this:
Not all the php files have html tag.
How can I do this with console?
Thanks _________________ embAD-new way to insert ads to your website |
|
Back to top |
|
 |
think4urs11 Bodhisattva


Joined: 25 Jun 2003 Posts: 6659 Location: above the cloud
|
Posted: Sat Apr 07, 2007 9:10 pm Post subject: Re: replace text in files with console |
|
|
something like this should do the trick Code: | for i in *; do sed -i '/s/\<html\>/\<html dir=\"rtl\"\>/' $i; done | ... (untested, out of head) _________________ Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself |
|
Back to top |
|
 |
BitJam Advocate

Joined: 12 Aug 2003 Posts: 2496 Location: Silver City, NM
|
Posted: Sat Apr 07, 2007 9:16 pm Post subject: |
|
|
Here is another untested solution: Code: | $ perl -ipe 's/<html[^>]*>/<html dir="rtl">/i' *.php |
|
|
Back to top |
|
 |
oc666 Guru

Joined: 15 May 2006 Posts: 330 Location: Israel
|
Posted: Sat Apr 07, 2007 9:27 pm Post subject: |
|
|
Both commands don't work.
I get for the first one (translated from hebrew): sed error in program - unknown command (char no. 4 of expr' -e no. 1)
I get for the second: Can't open perl script "s/<html[^>]*>/<html dir="rtl">/i": No such file or directory _________________ embAD-new way to insert ads to your website |
|
Back to top |
|
 |
BitJam Advocate

Joined: 12 Aug 2003 Posts: 2496 Location: Silver City, NM
|
Posted: Sat Apr 07, 2007 9:34 pm Post subject: |
|
|
Try: Code: | $ perl -i -p -e 's/<html[^>]*>/<html dir="rtl">/i' *.php |
|
|
Back to top |
|
 |
think4urs11 Bodhisattva


Joined: 25 Jun 2003 Posts: 6659 Location: above the cloud
|
Posted: Sat Apr 07, 2007 9:36 pm Post subject: |
|
|
Code: | for i in *.php; do sed -i 's/<html>/<html dir=\"rtl\">/' $i; done |
_________________ Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself |
|
Back to top |
|
 |
oc666 Guru

Joined: 15 May 2006 Posts: 330 Location: Israel
|
Posted: Sun Apr 08, 2007 9:14 am Post subject: |
|
|
Thanks a lot, Both works just fine. _________________ embAD-new way to insert ads to your website |
|
Back to top |
|
 |
|