Need help on creating a file everday with current date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help on creating a file everday with current date
# 1  
Old 02-27-2009
Need help on creating a file everday with current date

Hi Friends/Team,

I have written a small script but I dont understand what is the mistake in this one.. please help me identify and correct it.

file="touch `date +%b_%d`"
for i in $(cat /home/gmanju/servers)
do
echo $i >>file
remsh $i cat /var/opt/omni/server/log/opcmsg.log | grep -i "`date +%b` `date +%d`" | wc -l >>file
done


My requirement is like create a file everyday with preseent date and thereby the out put of my script should go to the created file. so that I can add this script in the cron job to execute everyday.

Please help!!!!
# 2  
Old 02-27-2009
This should work (Changes marked in bold):

Code:
file=`date +%b_%d`
touch $file
for i in $(cat /home/gmanju/servers)
do
echo $i >> $file
remsh $i cat /var/opt/omni/server/log/opcmsg.log | grep -i "`date +%b` `date +%d`" | wc -l >> $file
done


Last edited by ronnie_uk; 02-27-2009 at 09:56 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies

2. UNIX for Beginners Questions & Answers

“sed” replace date in text file with current date

We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ Code: line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to write a... (3 Replies)
Discussion started by: pradeepp
3 Replies

3. Shell Programming and Scripting

Subtract a file's modification date with current date

SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise Hi, In a folder, there are files. I have a script which reads the current date and subtract the modification date of each file. How do I achieve this? Regards, Joe (2 Replies)
Discussion started by: roshanbi
2 Replies

4. Shell Programming and Scripting

Get file name which include the current date

Hi, I'm trying to get the name of a file that has the current date in the name. The filename is on the form A<current date>01.DC, for example A2012110501.DC I have this script so far date +%y%m%d D=$(date +%y%m%d) N=A20$D echo $N N2={$N}01.DC echo $N2 And gets the following... (12 Replies)
Discussion started by: Immelstorn
12 Replies

5. Shell Programming and Scripting

current date modified file

Hi , In my directory , i have many days file but i want to see all those which are of todays date. i tried this but it gives all the files mtime -0 |ls -ltr I tried the below option as well. 19635 find -iname "*.LOG" -mtime 19636 ls -ltr *.LOG -mtime -1 19637 ls -ltr *.LOG... (7 Replies)
Discussion started by: guddu_12
7 Replies

6. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

7. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies

8. Shell Programming and Scripting

Perl: Extracting date from file name and comparing with current date

I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date. $file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z really appreciate any help. thanks mkneni (4 Replies)
Discussion started by: MKNENI
4 Replies

9. Shell Programming and Scripting

File date vs Current date

I am a newbie in shell scripting, hope you can advice how can I compare the date/time of file extracted from 'll' and current system date/time. I have done the following: ll -rt > $FILE_AGE_LOG FILE_DATETIME=`more $FILE_AGE_LOG | head -02 | cut -c 45-57` It returns 'May 4 19:11'. If I... (4 Replies)
Discussion started by: trexlim
4 Replies

10. UNIX for Dummies Questions & Answers

how to give current date in file name?

:) I want to rename a file by giving the actual date as a file name. Is there a command for this? For example file is this: a.txt I want to copy it with a command like this: a20050510.txt (3 Replies)
Discussion started by: simurg11
3 Replies
Login or Register to Ask a Question