Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 4 down vote accepted

Use sed. Here is an example:

sed "s/current_date/`date +%Y%m%d`/" infile > copyfile
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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