jeudi 17 août 2017

grep 2 elements in a line and print them

Here is my issue, i have a file with the entries, i would like to get just the date + the last command after the last "]: "

Aug 17 14:25:17 snaper[22134]: [ip:10.1.15.245 37985 10.1.15.18 22 uid:10000 sid:21680 tty: cwd:/data/www/hybris/hybris/bin/platform filename:/bin/ps]: /bin/ps -p 6763

How can i get it when i cat the file ?

I can get the date with:

awk '{print $1,$2,$3}'

and the last command with :

awk -F': ' '{print $NF}'

But how to combine them to get it in a single line ? I'm not awk limited, any sed grep or other command is ok for me :) Thanks in advance

Aucun commentaire:

Enregistrer un commentaire