![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| date calculation program | axes | High Level Programming | 1 | 09-12-2006 11:11 PM |
| find file with date and recursive search for a text | rosh0623 | UNIX for Advanced & Expert Users | 10 | 08-16-2006 03:27 PM |
| storing date into a file from a program | bankpro | High Level Programming | 2 | 01-17-2006 05:28 AM |
| may be simple but i don't know -- Print current date from C program | ls1429 | High Level Programming | 6 | 02-19-2002 01:50 AM |
| date program in ksh | krishna | UNIX for Advanced & Expert Users | 1 | 08-30-2001 01:43 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help in a Recursive date program!!!!
Hi,
I need a recursive program which when run appends todays date,month and year automatically to the existing file names.. I have aaa.txt file with some 90 odd file names. aa.bb_cc aa.bb_cc . . . aa.yy.zz When the script is run for today,it should give me like.. aa.bb_cc.Mar-23-2007 aa.bb_cc.Mar-23-2007 . . . aa.yy.zz..Mar-23-2007 and when the script is run for 2morrow,it should give me like aa.bb_cc.Mar-24-2007 aa.bb_cc.Mar-24-2007 . . . aa.yy.zz..Mar-24-2007 Or when the script has run for todays date,can we tell the script to automatically point to tomorrows date.Say after running Mar-23-2007,at the end it should point to Mar-24-2007. Can anybody help me with this program.... Thanks for you help, Kumar |
|
||||
|
Run this script once to add that days date Code:
dt=$( date "+%b-%d-%Y" )
for i in *
do
mv $i ${i}".${dt}"
done
Once the file has date in it use this script Code:
dt=$( date "+%b-%d-%Y" )
for i in *
do
mv $i ${i%.*}".${dt}"
done
|
|
||||
|
If my understanding on your problem is correct, the below one will take filenames from aaa.txt and rename it with the date details..
Quote:
|
|
||||
|
Quote:
./date.sh: syntax error at line 3: `suffix=$' unexpected #!/usr/bin/sh suffix=$(date+%d-%b-%y) while read line do { mv $line $line$suffix } done< /tmp/aaa/orig.txt |
|
||||
|
I am not finding any errors...
Quote:
|
|
||||
|
Quote:
#!/bin/tcsh dt=$(date"+%b-%d-%y") cd /tmp/aaa/ for i in * do mv $i ${i}".${dt}" done I get his error mesg when i execute the script..i dont know if i'm running it wrongly.. date1.sh: syntax error at line 4: `dt=$' unexpected |
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|