Copy file into multiple directories

Instead of running:

cp /path/to/file /usr/dir1
cp /path/to/file /var/dir2
cp /path/to/file /nas/dir3

Run the following command to copy file into multiple dirs:

echo /usr/dir1 /var/dir2 /nas/dir3 |  xargs -n 1 cp -v /path/to/file


Match a pattern and print whole line containing matched pattern.

Well.. I was wondering to capture whole line, when I have already one field, and I did it with the help of my friend via awk.

A simple “awk” trick to match a pattern and print whole line containing matched pattern.

# cat <any_large_file/log>|awk ‘$3 ~ /<pattern to look for>/ {print $_}’

It will match a pattern in 3rd field of supplied file and if pattern found whole row/line will be printed on standard output.


How you can empty your qmail queue

After a long time updating my blog. well I have many things to share but yes I will do it as soon as i get time.

For this time a small qmail queue deletion script tip as mentioned given.


#  STOP services of Qmail first
/sbin/service qmail stop or qmailctl stop

for i in bounce info intd local mess remote todo; do

find /var/qmail/queue/$i -type f -exec rm {} \;
/sbin/service qmail start

However, there are multiple ways to delete the qmail queue, but I prefer this because it worked like a charm!!