Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-09-02
3
Medium Priority
?
531 Views
Last Modified: 2013-11-22
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/
0
Comment
Question by:Geoff Millikan
3 Comments
 
LVL 16

Assisted Solution

by:medvedd
medvedd earned 800 total points
ID: 36474657
cat some_file.txt | grep some_search_term > output_file_`date`.txt
0
 
LVL 38

Accepted Solution

by:
wesly_chen earned 1200 total points
ID: 36480733
$ 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
 

Author Closing Comment

by:Geoff Millikan
ID: 36499501
Love the backtick operator, didn't know it could be used here like this.  Many thanks!!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded‚Ķ
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question