Saturday, August 7, 2010

How to remove Single Quote

I'd like to achieve the following :

Input Text :

'AAAAA','BBBBB','123456'
'CCCCCCCC','OKOKOKOKOK','2234222'
'FFF','ASDFASDF','123'


Expected output :

Remove single quotes.

AAAAA,BBBBB,123456
CCCCCCCC,OKOKOKOKOK,2234222
FFF,ASDFASDF,123



Here is the answer :


sed "s/'//g" input.txt >output.txt


Or if you have GNU sed

sed -i "s/'//g" input.txt

Cheers.

tail, grep, and logger (aka the output is being buffered!)

QUESTION :

When I do the following in bash shell, it works well.
[root@lwlx root]# tail -f -n 1 /u/email.log | logger

But, when I integrate the grep command, it stops working and not producing any output.
[root@lwlx root]# tail -f -n 1 /u/email.log | grep Blocked | logger

ANSWER :

The output of (tail -f) is being buffered. The above won't work. Please see the workaround as follow.

To release the buffer whenever there are new lines in the log if you suspect that the output is being buffered :

tail -f -n 1 /u/email.log | perl -ne 'BEGIN{$|=1}print if /blocked/' | logger

What if I want two or more filters such as "Blocked" or "Denied" or "Blacklisted":

tail -f -n 1 /u/email.log | perl -ne 'BEGIN{$|=1}print if /Blocked|Denied|Blacklisted/'

Cheers.

Friday, August 6, 2010

WinExe

Guess what!

When you need to execute commands in one or more remote MS Windows computers from local "MS Windows computer", yes, that's right, we got PsExec as a CLI solution.

What if you need to execute commands in one or more remote MS Windows computers from local "Linux or Unix" computer? Well, never fear, John! We got a tool called WinExe (an PsExec equivalent in Linux/Unix Platform).

http://sourceforge.net/projects/winexe/

PsExec

When you need to execute commands in one or more remote MS Windows computers from local MS Windows computer, PsExec is the CLI solution.

http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx