I have time like this 14:21:49
Now I need to remove the :
from the timestamp which means output should become like this 142149
Input:
scan_utc_input_time="14:21:49"
Output:
scan_utc_output_time="142149
I have time like this 14:21:49
Now I need to remove the :
from the timestamp which means output should become like this 142149
Input:
scan_utc_input_time="14:21:49"
Output:
scan_utc_output_time="142149
With tr
:
echo "14:21:49" | tr -d ':'
142149
sed
:
echo "14:21:49" | sed -e 's/://g'
142149
perl
:
echo "14:21:49" | perl -lpe 's/://g'
142149
In comments you have scan_utc_time=$(scan_utc_time | sed 's/[^0-9]*//g')
as what does not work.
That likely needs to be scan_utc_time=$(echo "$scan_utc_time" | sed 's/[^0-9]*//g')
ie, you are missing the sigil of $
to dereference the value. As habit, that should be quoted as well.
Plain shell parameter expansion:
scan_utc_output_time=${scan_utc_input_time//:/}