I want to print timestamp as one variable from the file content. I need awk command to ignore space between data and time. The value to be printed in $2 as SECOND_VALUE.
ex:
$ cat /var/tmp/file.txt
1#04-06-2019 03:06:17
Code:
list=`cat /var/tmp/${file}.txt`
for i in $list
do
FIRST_VALUE=`echo $i|awk -F'#' '{print $1}'`
SECOND_VALUE=`echo $i|awk -F '#' '{print $2}'`
done
output:
++ cat /var/tmp/file.txt
+ list='1#04-06-2019 03:06:17' '
+ for i in '$list'
++ echo 1#04-06-2019
++ awk -F# '{print $1}'
+ FIRST_VALUE=1
++ echo 1#04-06-2019
++ awk -F '#' '{print $2}'
+ SECOND_VALUE=04-06-2019
Exptected output:
SECOND_VALUE=04-06-2019 03:06:17