≡ Menu

regex

Sed: Find and Replace The Whole Line [ Regex ]

I have a line as follows in squid.conf file. My sever is hosted in a cloud:

acl verizonfios src 1.2.3.4

My ISP will force an IP address change every week or two. I would like to replace them with a new IP

acl verizonfios src 4.5.6.7

How do I replace the line starting with "acl verizonfios" with new IP address using sed and ssh?
[click to continue…]

I've over 1000's of files starting with _ character as follows:

_file1.txt
_foo1.txt
_2424.txt
_bar10000.txt

How do I remove the first character from a file name:

file1.txt
foo1.txt
2424.txt
bar10000.txt

[click to continue…]

I've central mail server gateway. All of our internal systems through this box. How do I remove or hide the hostnames and IP addresses of our internal systems from the messages headers before they go out to other users for security purpose?
[click to continue…]

Q. I'm using lighttpd under CentOS 5 and getting the following error:
...can't handle '$HTTP[url] =~ …' as you compiled without pcre support.

My question is What is pcre support, and how do I solve this problem?

A. Pcre is nothing but Perl-compatible regular expression library. PCRE has its own native API, but a set of "wrapper" functions that are based on
the POSIX API are also supplied in the library libpcreposix. You must compile lighttpd with pcre to support lighttpd regex style config option. pcre-devel package provides the development files (Headers, libraries for static linking, etc) for pcre. Install the following package and rebuild your lighttpd:
# yum install glib2-devel openssl-devel pcre-devel bzip2-devel gzip-devel

Now change directory to lighttpd source code and recompile Lighttpd with pcre option:
# make clean
# ./configure
# make
# make install

Now restart lighttpd and it should support pcre style config options.