Shell script string manipulation

January 28, 2011 at 20:04:09
Specs: centOS 5, 3Ghz/2GB
I'm trying to replace the epoch time at the end of the string below with a human readable date.


Using gawk, I can change the epoch time to the needed date.

gawk 'BEGIN{print strftime("%Y%m%d.%k%M",1296243507)}'

But being relatively clueless with shell scripting, I have no idea how to change the string. Can anyone point me in the right direction?


See More: Shell script string manipulation

Report •

January 30, 2011 at 22:39:05
If the Field Seperator is a period, assume that the second to the last field, NF-1, is what needs to be changed:

nfile=$(echo "XXXX-XXX-2011-01-25-3.6.2-record.pb.1296066338.gz"|
gawk ' BEGIN { FS="."; OFS="." }
print $0
}' )

echo $nfile

Report •
Related Solutions

Ask Question