I have to extract number part (Date and timestamp part ) from the following 3 strings
AB_XYZA_20130930183017.log
AB_DY_XYZA_20130930183017.log
AB_GZU_20130930183017.log
Output should be
20130930183017
Please help me to get the string like above
Thanks
Subbeh
2
With grep:
grep -o [0-9]* inputfile
awk:
awk -F'[_.]' '{print $(NF-1)}' inputfile
You may try this also...
$ cat <<EOF | awk '{gsub(/[A-Za-z._]/,x,$0);1}1'
AB_XYZA_20130930183017.log
AB_DY_XYZA_20130930183017.log
AB_GZU_20130930183017.log
EOF
20130930183017
20130930183017
20130930183017
$ cat <<EOF | sed 's/[A-Za-z._]//g'
AB_XYZA_20130930183017.log
AB_DY_XYZA_20130930183017.log
AB_GZU_20130930183017.log
EOF
20130930183017
20130930183017
20130930183017
1 Like