rpk2008
1
Hi All,
I need to replace the last 19 bytes of the following string
My_Org_Testing_20090102_231124.txt (Text_Date_Time.txt).
I would like to derive the current time using "date +%Y%m%d_%H%M%S.txt" and replace the last 19 bytes of the above string
I would appreciate if someone could help me on this.
Thanks in advance
Regards,
Rohan
Something like this.
var=My_Org_Testing_20090102_231124.txt
echo $var| sed 's/My_Org_Testing_\(.*\)/My_Org_Testing_'$(date +%Y%m%d_%H%M%S.txt)'/
$ s="My_Org_Testing_20090102_231124.txt"
$ echo ${s%???????????????????}$(date +%Y%m%d_%H%M%S.txt)
skmdu
4
$ echo "My_Org_Testing_20090102_231124.txt" | sed "s/.\{19\}$/$(date +%Y%m%d_%H%M%S.txt)/"