LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-13-2006, 02:56 AM   #1
abubin
LQ Newbie
 
Registered: Jun 2006
Posts: 3

Rep: Reputation: 0
linux commandline scripting


Hi guys,

Need help from someone who is expert in commandline scripting.

I want to create an automated script copy a file from <source> to <target_date>. Where the target have the target name and date included into the filename.

Example,

cp filename /home/username/target_110106

The problem is, I don't know how to include that date into the filename in the script. I know how to retrieve that date in ddmmyy format (using date command) but how to include it into the cp command in the script?

Appreciate some help. Thanks in advance.
 
Old 06-13-2006, 03:23 AM   #2
nitroid
Member
 
Registered: Jul 2004
Location: Finland
Distribution: Arch and Maemo (N900)
Posts: 32

Rep: Reputation: 15
Try it like this:
Code:
cp filename /home/username/target_$(date +%e%m%y)
That gives the date in day, month, year order. Swith %e and %m around if you need it in month, day, year instead.
 
Old 06-13-2006, 05:07 AM   #3
abubin
LQ Newbie
 
Registered: Jun 2006
Posts: 3

Original Poster
Rep: Reputation: 0
done, thanks for the help!!
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
Remote CommandLine moejoe Linux - Networking 1 12-28-2004 10:40 AM
using mcrypt from commandline Hano Linux - Security 5 12-11-2004 09:17 AM
want to use Variable as commandline clsonnt Programming 2 10-28-2004 11:55 AM
Adding an interface to commandline Linux tarballedtux Linux - Networking 1 11-15-2001 11:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:46 AM.

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