![]() |
|
|
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 |
| getting date from timestamp | pavan_test | UNIX for Dummies Questions & Answers | 2 | 09-28-2006 01:01 PM |
| get a file date/timestamp | alex31 | UNIX for Dummies Questions & Answers | 3 | 12-22-2005 10:06 AM |
| renaming the file with the timestamp | ajubi | Shell Programming and Scripting | 6 | 12-05-2005 06:21 AM |
| how attached date when renaming log file | ukadmin | Shell Programming and Scripting | 2 | 08-11-2003 11:42 AM |
| Creating file with date/timestamp in it | ccpjr29 | Shell Programming and Scripting | 7 | 03-04-2002 04:14 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
File renaming with date timestamp
Hi,
This is my script: #! /usr/bin/ksh cd /app/chdata/workflow/suppl/esoutput/spd/testing for file in /app/chdata/workflow/suppl/esoutput/spd/testing do sort *.txt | awk '{ file=substr($0,1,2)".txt"; print >> file }' mv *.txt file_`date +"%Y%m%d%H%M%S"`.txt done Here, I am trying to rename all the files say *.txt to *_date.txt. However, Its throwing an error. Please help. Regards, Sunitha |
|
||||
|
You probably mean Code:
for file in *.txt; do mv "$file" file_`date +"%Y%m%d%H%M%S"`.txt done The sort | awk seems to be entirely unrelated to this problem. It should not be inside the for loop if you don't really mean for it to also operate on each file in *.txt separately (then similarly using "$file" as the argument to sort instead of *.txt). |
![]() |
| Bookmarks |
| Tags |
| date timestamp, file rename |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|