≡ Menu


Linux / UNIX: Run Command a Number of Times In a Row

How do I run "foo" command 10 times (or n times) under Linux or UNIX like operating systems?
[click to continue…]

Linux: Rename Expression To Remove First Character From a File Name

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


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


[click to continue…]

CentOS / RHEL: Install PostgresSQL Interface for Perl (perl-DBD-Pg)

How do I install PostgresSQL interface for perl for programming purpose under Redhat / RHEL / Fedora / CentOS Linux?
[click to continue…]

Linux / UNIX: Convert Epoch Seconds To the Current Time

How do I convert Epoch seconds to the current time under UNIX or Linux operating systems?
[click to continue…]

MySQL: Find Out Which Table is Consuming Resources

Q. How do I find out which table is consuming resources under MySQL Database server from UNIX shell prompt?
[click to continue…]

How do I Be More Productive In Vim?

This is a user contributed FAQ.

Q. I'm just starting in vim text editor but I'm annoying typing and retyping similar statements. Can you address me about it?
[click to continue…]

Linux / UNIX Display Lines Common in Two Files

Q. I'm trying to use diff command, but it is not working. I'd like to display those lines that are common to file1 and file2? How do I do it?
[click to continue…]

Bash Shell: Replace a String With Another String In All Files Using sed and Perl -pie Options

How do I replace a string with another string in all files? For example, ~/foo directory has 100s of text file and I'd like to find out xyz string and replace with abc. I'd like to use sed or any other tool to replace all occurrence of the word.
[click to continue…]

Lighttpd as you compiled without pcre support error and solution

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.

Linux: Find my IP address using Perl at a shell prompt

Q. How do I find out my IP address assigned to eth0 or ra0 interface using perl?

A. If you need to know the IP address of the UNIX / Linux machine you are running on, use the following perl one liner. Perl don't have any inbuilt facility but combination of ifconfig command ans shell pipes you can craft something as follows to display your system IP address:

Find my IP address using Perl One liner and shell pipes

Type the following command at a shell prompt:

ifconfig -a | perl -ne 'if ( m/^\s*inet (?:addr:)?([\d.]+).*?cast/ ) { print qq($1\n); exit 0; }'