Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-02
3
Medium Priority
?
530 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…
Suggested Courses

715 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