Solved

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

Posted on 2011-09-02
3
511 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
ID: 36474657
cat some_file.txt | grep some_search_term > output_file_`date`.txt
0
 
LVL 38

Accepted Solution

by:
wesly_chen earned 300 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
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.

785 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