I'm writing a script to publish a webapp. While copying files, I must replace a placeholder current_date in a file with the current date.

I would start with something like this to define the date string

date=`date +%Y%m%d`

The copy and replace part is where I don't know how to start.


Use sed. Here is an example:

sed "s/current_date/`date +%Y%m%d`/" infile > copyfile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.