The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sorting Files by date and moving files in date order rebel64 Shell Programming and Scripting 2 03-11-2008 12:45 PM
Find all the files after the date? gkrishnag UNIX for Advanced & Expert Users 1 09-11-2006 12:15 PM
how to remove files with a date justintime Shell Programming and Scripting 5 09-10-2006 10:50 PM
deleting files on particular date jazz High Level Programming 1 11-24-2005 11:45 AM
use of date in LOG FILES! how to? kymberm Shell Programming and Scripting 6 07-18-2002 03:33 PM

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

Join Date: May 2006
Posts: 16
How to copy set of files with date appended to their name

Hi gurus,

I have set of files in a directory

ex : test_file1.csv
test_file2.csv
test_file3.csv

my requirement is to copy these files into another directory but with date appended to the name :

like after copying the files should look like : test_file1_07072008.csv
test_file2_07072008.csv
test_file3_07072008.csv

is this possible an di fpossible can we perform in a single unix command?

any help is apprecaited.

thanks
  #2 (permalink)  
Old 07-07-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,892
You can write something like this:

Code:
dt=$(date +%d%m%Y)
for f in *csv; do 
  mv "$f" another_directory/"${f%.csv}_$dt.csv"
done
  #3 (permalink)  
Old 07-07-2008
sish78 sish78 is offline
Registered User
  
 

Join Date: May 2006
Posts: 16
thanks for the prompt response, is there nay other way of doing it

--like using in a single unix command line.
  #4 (permalink)  
Old 07-07-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,892
There are many ways of doing it, the question is why you don't want to use the one above ...
  #5 (permalink)  
Old 07-07-2008
sish78 sish78 is offline
Registered User
  
 

Join Date: May 2006
Posts: 16
I'm using an ETL TOOL which takes an unix command with parmaeters, so i was looking at that method only.
  #6 (permalink)  
Old 07-07-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,892
What are the parametrs that you want to pass? Destination directory and filenames?
  #7 (permalink)  
Old 07-07-2008
sish78 sish78 is offline
Registered User
  
 

Join Date: May 2006
Posts: 16
Yes. source directory ,destination directory and file pattern.
Closed Thread

Bookmarks

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 07:00 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