Hi,
I have a file which contains the below data. I want to change pattern to correct format.
[root@ client]# tail -1 test.log | awk '{print $8}'
10/09/23
[root@client]#
I want the format to be 23/09/10
Hi,
I have a file which contains the below data. I want to change pattern to correct format.
[root@ client]# tail -1 test.log | awk '{print $8}'
10/09/23
[root@client]#
I want the format to be 23/09/10
try this,
tail -1 test.log | awk '{print $8}' | perl -nle 'if (/(\d{2})\/(\d{2})\/(\d{2})/) {print $3,"/",$2,"/",$1} ;'
Thanks it working
[root@a client]#tail -1 test.log | awk '{print $8}' | perl -nle 'if (/(\d{2})\/(\d{2})\/(\d{2})/) {print $3,"/",$2,"/",$1} ;'
23/09/10
[root@a client]#
But I was checking with sed command
# tail -1 test.log | awk '{print $8}' | sed 's|\(.*\)/\(.*\)/\(.*\)$|\3/\2/\1|'
23/09/10
Thanks
all in one.
awk 'END{split($8,a,"/");print a[3],a[2],a[1]}' OFS="/" test.log