a SED/AWK way to remove everything except...

Hi all,

I have a logfile which has lines as following:
DOMAIN\username,Deposit,DOMAIN\ServiceAccountName,25/03/2010,00:10,\\SERVER,,,,/Ts=4BAA9BD6,,,10.00,10.03

It's a log of a pcounter print charge system.
I need to only have the first part (domain\username) and the second last (deposited balance) for a other script to make the balance deposits right.
I have a PC_TODAY.LOG which contains 141 lines of above example.

Thanks for the help.

Regards.

$ echo DOMAIN\username,Deposit,DOMAIN\ServiceAccountName,25/03/2010,00:10,\\SERVER,,,,/Ts=4BAA9BD6,,,10.00,10.03 |
> awk -F"," ' { print $1 , $(NF-1) } '
DOMAINusername 10.00

Thanks alot for the quick response anbu23,

As I mentioned, its a logfile with more then one line (141 lines to be exact).

$ cat PC_TODAY.LOG | awk -F "," ' { print $1 , $(NF-1) } '

Works like a charm!
Thx :slight_smile:

No cat in the forum. :slight_smile:

awk -F "," ' { print $1 , $(NF-1) } ' PC_TODAY.LOG
s="DOMAIN\username,Deposit,DOMAIN\ServiceAccountName,25/03/2010,00:10,\\SERVER,,,,/Ts=4BAA9BD6,,,10.00,10.03"
echo $s | sed 's/\(.[^,]*\).*,\(.[^,]*\),\(.[^,]*\)/\1 \2/'