LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-10-2004, 03:53 AM   #1
parker
LQ Newbie
 
Registered: Aug 2003
Posts: 10

Rep: Reputation: 0
Question Creating a file like "DATE.txt"


Hello!

i'm running a daily cronjob (simple snmpgets written in bash) and want the output being written into a file DATE.txt.
any suggestions?

TIA, Parker

Last edited by parker; 03-10-2004 at 04:08 AM.
 
Old 03-10-2004, 04:38 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,523

Rep: Reputation: 365Reputation: 365Reputation: 365Reputation: 365
command > DATE.txt
 
Old 03-10-2004, 04:38 AM   #3
guygriffiths
Member
 
Registered: Jun 2003
Location: Reading, UK
Distribution: Debian 3.0, LFS
Posts: 524

Rep: Reputation: 35
Something like this:
Code:
variables=predefined strings
cat >> DATE.txt << EOF
Write whatever you want to go into the file here
You can use $variables if you want to
To end input, type:
EOF
Will give you a file that looks like this:

Write whatever you want to go into the file here
You can use predefined strings if you want to
To end input, type:

Also you can use:
echo -e "Some text that you want\nThe -e option allows for special characters" >> DATE.txt

Again you can use variables. The ">>" means append, but you can use ">" if you want to start a new file in both cases.
 
Old 03-10-2004, 04:54 AM   #4
cjcuk
Member
 
Registered: Dec 2003
Distribution: Openwall, ~LFS
Posts: 128

Rep: Reputation: 15
Not too sure, but do you mean more how can you create a file DATE.txt where DATE is today's date? You can use the date command to create a filename for yourself. For example:

Code:
run_program > "`date +%Y%m%d%H%M%S`.txt"
Will attach the standard out of `run_program' to a file of the format YYYYMMDDHHMMSS.txt, I think this is what you mean?
 
Old 03-10-2004, 05:44 AM   #5
parker
LQ Newbie
 
Registered: Aug 2003
Posts: 10

Original Poster
Rep: Reputation: 0
that's it cjcuk

thanks a lot, thats what i was looking 4.

cu, parker
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"creating symbolic link" "operation not permitted" wheni Linux - Newbie 3 05-08-2011 02:36 AM
cannot exit normally after "nohup blablabla > output.txt &" LQYY Linux - Newbie 1 12-14-2004 11:02 AM
Could someone please post "upgrade.txt"... tigerflag Slackware 2 06-27-2004 05:52 PM
Creating an "all in one" install file? Agileuk Linux - General 1 10-07-2003 06:16 AM
Monthly Archiving Script... help with "date" & "cron" Supp0rtLinux Linux - Software 3 01-03-2003 10:29 PM


All times are GMT -5. The time now is 02:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration