Solved

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

Posted on 2011-09-02
3
500 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 200 total points
Comment Utility
cat some_file.txt | grep some_search_term > output_file_`date`.txt
0
 
LVL 38

Accepted Solution

by:
wesly_chen earned 300 total points
Comment Utility
$ 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
Comment Utility
Love the backtick operator, didn't know it could be used here like this.  Many thanks!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now