PDA

View Full Version : help with perl



walo
04-19-2007, 06:19 PM
i need to make a line script than can remove a specific line from the httpd.conf file

I get this, but it doesn't work

perl -ni -e 'unless (m//usr/local/directadmin/data/users/myuser/httpd.conf$/) { print }' /etc/httpd/conf/httpd.conf 2>&1Which i need to remove is a line like this one:

Include /usr/local/directadmin/data/users/myuser/httpd.conf

l0rdphi1
04-26-2007, 10:53 AM
i need to make a line script than can remove a specific line from the httpd.conf file

I get this, but it doesn't work

perl -ni -e 'unless (m//usr/local/directadmin/data/users/myuser/httpd.conf$/) { print }' /etc/httpd/conf/httpd.conf 2>&1Which i need to remove is a line like this one:

Include /usr/local/directadmin/data/users/myuser/httpd.conf
Hello,

If you want to remove that quoted Include statement, you could do something like this with Perl:
perl -pi -e 's!Include\s/usr/local/directadmin/data/users/[^/]+/httpd.conf!!g' /usr/local/directadmin/data/users/*/httpd.conf
Note that won't get rid of the trailing line break, and if you don't want to remove the line for ever user, make sure to replace the * with a username.

Good luck.

walo
04-26-2007, 10:59 AM
Thank you !!