Hello all.

New here. Another student looking for a little help. Technically I wouldn't consider this a homework question, as it is part of a much larger project for my class. My professor is little help so I'm here now. I hope you can help.

I have a text file, and I need to print today's date at the end of the last line and in MM/DD/YYYY format.

What is in bold is what I have trouble with.

Recommended Answers

All 4 Replies

date +%m/%d/%Y will give you the proper format, but i'm not sure how you would append it to the last line.

Hello all.

New here. Another student looking for a little help. Technically I wouldn't consider this a homework question, as it is part of a much larger project for my class. My professor is little help so I'm here now. I hope you can help.

I have a text file, and I need to print today's date at the end of the last line and in MM/DD/YYYY format.

What is in bold is what I have trouble with.

I think it depends on the circumstances, but an easy way is:

echo \ date >> file

Mix sknake and hilliard solution

echo `date +%m'/'%d'/'%Y` >> file

That will append the date to a new line, not the end of the last line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.