The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
How to Zip the files from date Stamp to end date Stamp redlotus72 UNIX for Dummies Questions & Answers 1 12-08-2006 06:29 PM
creating a new file with date stamp mgirinath Shell Programming and Scripting 2 02-28-2006 12:00 PM
Inserting Date&Time Stamp In Existing Log File shephardfamily UNIX for Dummies Questions & Answers 3 02-24-2006 04:01 AM
ftp copy: preserve source file date stamp cassj UNIX for Dummies Questions & Answers 5 02-16-2005 06:38 PM
File date and time stamp Xenon UNIX for Dummies Questions & Answers 1 10-09-2001 03:58 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-08-2006
lweegp lweegp is offline
Registered User
  
 

Join Date: Oct 2005
Location: singapore
Posts: 107
Date Stamp on new file

Dear Gurus,

I'm trying to move a number of files from one directory to another directory with a new date stamp. This is my script:

#! /bin/csh

Today_Date=`date +%Y%M%D`
mv /usr/TRS/data/TS* /usr/TRS/backup/TS*.${Today_Date}

when i run the script i'm getting the following errors:

mv: /usr/TRS/backup/TS*.20062309/08/06 not found

Any advise?

Thanks

wee
  #2 (permalink)  
Old 09-08-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
what is the date format that u want exactly ?

date +%Y%M%D

%M - minute format

is of the format

YYYYMMMM/DD/YY

YYYYMMDD
try this,

Code:
date +%Y%m%d
  #3 (permalink)  
Old 09-08-2006
lweegp lweegp is offline
Registered User
  
 

Join Date: Oct 2005
Location: singapore
Posts: 107
hi thanks for the help. i get the date though (see below), but getting another error message:

mv: /usr/TRS/backup/TS*.20060908 not found

any advise? thanks again.


wee
  #4 (permalink)  
Old 09-08-2006
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
Quote:
Originally Posted by lweegp
hi thanks for the help. i get the date though (see below), but getting another error message:

mv: /usr/TRS/backup/TS*.20060908 not found

any advise? thanks again.


wee
i think the destination should not have a '*' ... it should be a valid directory, or a filename.
  #5 (permalink)  
Old 09-08-2006
lweegp lweegp is offline
Registered User
  
 

Join Date: Oct 2005
Location: singapore
Posts: 107
Quote:
Originally Posted by ghostdog74
i think the destination should not have a '*' ... it should be a valid directory, or a filename.
thanks. somehow it solved my problem. this is how my script looks like:

#! /bin/sh

Today_Date=`date +%Y%m%d`

mkdir /usr/TRS/backup/${Today_Date}

mv /usr/TRS/data/T* /usr/TRS/backup/${Today_Date}

so now i will create today's date as a directory and put all the files in.

the question is how do i remove those directory when they are more than 10 days old? thanks again.
  #6 (permalink)  
Old 09-08-2006
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
Quote:
Originally Posted by lweegp
the question is how do i remove those directory when they are more than 10 days old? thanks again.
you can use the find command with -mtime switch. Please do "man find" and see how it is used or you can search the forum
Closed Thread

Bookmarks

Tags
mtime

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0