16

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

28

Use sed. Here is an example:

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.