Linux > Pipe output on command line to a dynamically named file?

In the command line, how do I add the datetime into the output file name?

$ cat some_file.txt | grep some_search_term > output_file_[datetime_stamp].txt

Thanks,

http://www.t1shopper.com/
Geoff MillikanAsked:
Who is Participating?
 
wesly_chenConnect With a Mentor Commented:
$ cat some_file.txt | grep some_search_term > output_file_`date +%Y+m%d-%H%M`.txt
where
   date +%Y+m%d-%H%M
  gives the time stamp output format as   20110903-1020

do
  man date
   for more details.
0
 
medveddConnect With a Mentor Commented:
cat some_file.txt | grep some_search_term > output_file_`date`.txt
0
 
Geoff MillikanAuthor Commented:
Love the backtick operator, didn't know it could be used here like this.  Many thanks!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.