I have a file, cache.md, that starts off like this:
# 2012-05-09.8271
CACHE MANIFEST
CACHE:
/index.html
I’m trying to write a shell script (using Automator in OS X Lion) to replace the first line and change the text (after the hash) to today’s date, a dot, and a random number.
Here’s the bash script I have so far, but it doesn’t do anything.
_now=$(date +"%Y-%m-%d")
_rand=$RANDOM
sed -i '' '1 s/[\d\-\.]+/$_now.$_rand/' ~/Desktop/cache.mf
Use this sed command: