Hi ,
I have a file (input.txt) with the below contents :
20150223T12:00:25 hostnamex
20150716T10:40:54 hostnamey
20150202T20:08:03 hostnamez
I want the output to be like below i.e excluding the timestamp ( THH:MM:SS) in the above file as follows :
20150223 hostnamex
20150716 hostnamey
20150202 hostnamez
I have tried the following sed command but it is giving only date and the second field is not getting displayed :
sed -n 's/T.*\([^[:blank:]]*\).*\([^[:blank:]]*\).*/\1 \2/p' input.txt
Output :
20150223
20150716
20150202
Could someone please help me and explain it. Thanks a lot .
Rahul