Web Hosting Talk







View Full Version : search and replace command line


dave_s_wang
11-02-2005, 07:06 PM
need help with my command line skills.....

example:
i want to remove #!/usr/local/bin/php from my *.php files

so far i have:

find . -name "*.php" | xargs --replace {} sed 's/\#\!\/us\r/local\/bin\/php//g' > {}

but it doesn't seem to work because its creating a file {}. Can someone help me out? Thanks!

dave_s_wang
11-02-2005, 11:25 PM
find . -name "*.php" | xargs sed -i 's/\#\!\/usr\/loca\/bin\/php//g'

kalpin
11-14-2005, 01:56 AM
Should be: find . -name "*.php" | xargs sed -i 's/\#\!\/usr\/local\/bin\/php//g'

apex13
11-15-2005, 04:18 PM
sed -i doesn't work in all Unixes...also you don't have to escape all that stuff...so here's another much more compatible version:

find . -name \*.php -print | xargs perl -pi.bak -e s',#!/usr/local/bin/php,,g'

It'll keep you backup copies and is compatible with every flavor of Unix :)