Hi PHV,
Thanks for this, and it works great.
However, now I need to put this into a perl script & I am having issues with getting it to work. I have tried backticks, qq etc. and no good. Any ideas how to make this work within a perl script?
I run this ->
my $tmpfile_2 = qq|/tmp/somefile2.bak|;
my $awk_cn_command = qq|awk 'NR>1 && !/cn=/{printf '"\n"'}{printf '"%s"',$0}END{printf '"\n"'}' $logout > tmpfile_2|;
print $awk_cn_command;
qx|$awk_cn_command|;
and the output I get is;
awk 'NR>1 && !/cn=/{printf '"
"'}{printf '"%s"',./login_errors.pl}END{printf '"
"'}' /tmp/failure.log > tmpfile_2awk: syntax error near line 2
awk: illegal statement near line 2
so the /n is breaking it for some reason...