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.

1 Answer 1


Use sed. Here is an example:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .