Retreiving and storing date...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Retreiving and storing date...
# 1  
Old 03-03-2009
Retreiving and storing date...

First of all want to apologize for such a simple question. Very "new" to UNIX and have just taken a small intro class.

I need to pull back YYYYMMDD and store it in a field to be used later. I figured out date "+%Y%m%d" returns the date in that format, just not sure how to store it.
I am going to be emailing a file that is called for example report20090303.txt.
# 2  
Old 03-03-2009
touch report`date "+%Y%m%d"`.txt
# 3  
Old 03-03-2009
Quote:
Originally Posted by Radar
touch report`date "+%Y%m%d"`.txt
Code:
touch `date 'report+%Y%m%d'`.txt

# 4  
Old 03-03-2009
Don't really understand what the "touch" does. I thought this would work, but it isn't...

Store the Date as follows:

DATE=$(date +%Y%m%d)

Then email it like this...
cat '${report_file}$DATE.txt' >> mailfile
echo "
--^A^A^A^A^A--" >> mailfile

sendmail ${recip_adr} < mailfile

I am getting the following error though:
Cannot open ${report_file}$DATE.txt. Why is it not resolving the symbolics?
# 5  
Old 03-03-2009
the touch command create an empty file.

try it like that:

Code:
DATE=`date +%Y%m%d`

Then email it like this...
cat ${report_file}${DATE}.txt >> mailfile
echo "
--^A^A^A^A^A--" >> mailfile

sendmail ${recip_adr} < mailfile

# 6  
Old 03-03-2009
Thanks, I am getting closer...

now it is putting 'date +%Y%m%d' in {DATE}, not the value 20090303.
# 7  
Old 03-03-2009
Make sure you have a backtick (`) not a single quote ('). Its doesnt have the same effect.

You should have that :

Code:
DATE=`date +%Y%m%d`

and not :

Code:
DATE='date +%Y%m%d'

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Matching and retreiving numbers

Hi, I have one file 1.txt with one field consist of following Ids (shortlisted 10 but showing 3 here): 00052 00184 00607 and then second file 2.txt with three fields (very big file): 00052 00184 12.73062 00052 00598 13.51205 00052 00599 13.92554 00052 00600 13.73358... (2 Replies)
Discussion started by: bioinfo
2 Replies

2. Shell Programming and Scripting

perl : searching for month and storing the date and time in an array

I am writing the code in perl. I have an array in perl and each variable in the array contains the data in the below format Now I need to check the below variable w.r.t system month I need to store the date and time(Tue Aug 7 03:54:12 2012) from the below data into file if contains only 'Aug'... (5 Replies)
Discussion started by: giridhar276
5 Replies

3. Shell Programming and Scripting

Retreiving part of a mail ID

Hi all, I want to retrieve a part of the mail ID. Im using Ksh. The mail ID's i handle are of the type: abc.def@ghi.com I want the abc part alone. Here is the code i used: a=`echo $mailid |sed 's/\(.*\)..../\1/'` echo $a but the output i get is abc.def@ghi I dont know... (2 Replies)
Discussion started by: Jayaraman
2 Replies

4. Shell Programming and Scripting

Help needed in retreiving records from Oracle

Hello, I am new to UNIX. My Requirement: Need to connect to Oracle database from UNIX and execute an SELECT statement and store the records in a flatfile of Comma delimiter. What I have Succeeded: I was able to connect to Oracle from UNIX. Problem: I cannot fetch multiple... (3 Replies)
Discussion started by: arunvasu2
3 Replies

5. UNIX for Dummies Questions & Answers

Help with retreiving files' information stored in different directories.

Dear All, I have a question. I have similarly named files stored in different directories and I'd like to retreive information from them remotely to perform other tasks. For example given: Folder 5 has files S5_SK1.chr01 S5_SK1.chr02 ....... Folder 6 has files S6_SK1.chr01 ... (3 Replies)
Discussion started by: pawannoel
3 Replies

6. UNIX for Dummies Questions & Answers

retreiving file name in a variable on ftp

Hi , I need to retreive the file name in an variable on the ftp server.Can you guy please let me know how can i do that.I need some thing like connect to ftp <<eof new_variable=`ls *_1_AUDIT.txt *_2_AUDIT.txt` (but on a ftp server) mget $new_variable >>eof (1 Reply)
Discussion started by: Param0073
1 Replies

7. Shell Programming and Scripting

Retreiving information from a text file

Hey guys, i just started shell programming and i have a question. I am working on a simple inventory project and one of the problems which i am unable to solve would be how i am going to extract the data i need from a text file(which will be my database) and then put it inside the executable to be... (5 Replies)
Discussion started by: gregarion
5 Replies

8. Shell Programming and Scripting

date capturing regex and storing

Hi all I need help on how to store two or more date formates captured using regex from an input sentence in PERL ? For example, I have an input sentence consisting of two dates such as : The departure date is August 12, 2009 and arrival date is 20.08.2009. Now, I want to capture the two... (4 Replies)
Discussion started by: my_Perl
4 Replies

9. UNIX for Dummies Questions & Answers

Retreiving live data

I have a stream of data come to a server and store in a file (datafile). This stream of data contain a lot of information. Data could come in every second or different frequency of times. I like to retrieve a certain text string as the data come in. All data information will come with the... (1 Reply)
Discussion started by: bobo
1 Replies

10. Programming

storing date into a file from a program

hi all: i want to store the current date in to a file from a program. every time i execute the prg the date should get appended into the file. help me plz (2 Replies)
Discussion started by: bankpro
2 Replies
Login or Register to Ask a Question