LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-21-2005, 03:36 AM   #1
hrafn
LQ Newbie
 
Registered: Mar 2005
Posts: 1

Rep: Reputation: 0
Finding the last in a file list ..


Hi,

I'm making a bash script and I need to have it copy files to a new name with a date suffix like:

cp file1 file1%Y%m%d%H%M

whoud give me: file1200503210936

How can I actually make this thing work ?

thanks.

Last edited by hrafn; 03-21-2005 at 03:37 AM.
 
Old 03-21-2005, 03:45 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

This will work:
cp file1 file1.`date '+%Y%m%d%H%M'`

If all the files need the same date stamp you could store the date string in a variable and append that variable to the filename:

DATE="`date '+%Y%m%d%H%M'`"
cp file1 file1.${DATE}


Hope this helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding the file size harrylmh Programming 8 04-29-2006 03:59 PM
Finding a specific file j_carmona Linux - Newbie 12 05-02-2005 07:42 PM
Finding File Size cmfarley19 Linux - General 1 01-24-2005 08:36 AM
finding most recent file wedgeworth Linux - Software 3 10-22-2003 01:53 PM
finding a file pcdebb Linux - Newbie 8 10-21-2003 06:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration