15
Aug

use “find” cgi/perl file in web server with directadmin

find /home/*/domains/*/public_html/cgi-bin/ -iname *.cgi -ls
find /home/*/domains/*/public_html/cgi-bin/ -iname *.pl -ls
find /home/*/domains/*/private_html/cgi-bin/ -iname *.cgi -ls
find /home/*/domains/*/public_html/cgi-bin/ -iname *.pl -ls

use “find” search text in file

find . -type f -name '*.php' -print | xargs grep 'iframe'
find . -type f -name '*.html' -print | xargs grep 'iframe'
find . -type f -name '*' -print | xargs grep 'iframe'

use “find” & linux command

find /home/ -type f -iname index.htm -exec rm -fv {} ;

use “perl” search & replace

#search "cgi=ON" and replace to "cgi=OFF"
perl -pi -e 's/cgi=ON/cgi=OFF/' /usr/local/directadmin/data/users/*/user.conf
perl -pi -e 's/cgi=ON/cgi=OFF/' /usr/local/directadmin/data/users/*/reseller.conf
perl -pi -e 's/cgi=ON/cgi=OFF/' /usr/local/directadmin/data/users/*/domains/*.conf
#search "<script src=http://achtbanen.org/images/b-one-default.php ></script>" and replace to blank
perl -pi -e 's/<script src=http://achtbanen.org/images/b-one-default.php ></script>//g' ./*.html

use “sed” search & replace

#search "disable = yes" replace to "disable = no" in file "file.conf"
sed -e '/disable/ s/yes/no/' -i /file.conf
#search "mysql_query" replace to "mysql_do_query" and write to "newfile.conf"
sed 's/mysql_query/mysql_do_query/g' > newfile.conf

use “grep” search text in file

grep -iR "_0.mx" /var/log/proftpd/*
grep -iR "cgi-bin" /var/log/proftpd/*

use “cat” & “grep” search text in file

cat /var/log/proftpd/* |grep "text" |more
cat /var/log/proftpd/* |grep "text" |grep -v "notext"

Short link: http://taxze.com/?p=23
Canonical link: http://www.taxze.com/search-replace-with-findperlsed-linux-command/


sed replace *.html, sed -n linux command,

Leave a Reply “Search replace with find,perl,sed Linux command”