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.

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

E.g. at the end of the session for each day I want to create a history file with the date attached at the end.

So, say, history > history07162012.txt or something like that.

share|improve this question
I would suggest using a standard timestamp instead of your US specific and unsortable one, i.e. history20120716.txt by using date +%Y%m%d – jlliagre Jul 17 '12 at 11:53
up vote 5 down vote accepted

Assuming history files are hidden (beginning with .), I would do like:

ls -1 ~/.*history

With output:



for hist_file in ~/.*history; do cp "$hist_file" "$hist_file$(date +%m%d%Y).txt"; done

And then:

ls -1 ~/.*history*

With following output:


I hope it can be useful for your question.

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.