Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 3 down vote accepted

Use sed. Here is an example:

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

Your Answer

 
discard

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.