LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris and OpenSolaris.
General Sun, SunOS and Sparc related questions also go here.

Notices

Reply
 
LinkBack Search this Thread
Old 11-17-2004, 07:53 AM   #1
markraem
Member
 
Registered: Nov 2003
Posts: 82

Rep: Reputation: 15
adding date timestamp to filename


I am looking under solaris to the following :

:start
date
cp filename filename19:23:33
goto start

where 19:23:33 is the time when the cp has to be done.

I know it is possible under linux :

#!/bin/bash

filename="date.txt"
timestamp=(date '+H:%M:%S' )
fullname=$filename$timestamp
cp date.txt $fullname


But how can I do it under Solaris ?

Tnx in advance
 
Old 11-17-2004, 08:04 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Ubuntu, OEL
Posts: 9,165

Rep: Reputation: 243Reputation: 243Reputation: 243
This works the same (typos aparts) under Solaris ksh or bash, e.g.:
Code:
#!/bin/ksh
filename=date.txt
cp $filename $filename$(date '+%H:%M:%S')
 
Old 11-17-2004, 08:32 AM   #3
markraem
Member
 
Registered: Nov 2003
Posts: 82

Original Poster
Rep: Reputation: 15
This works indeed correct !

tnx for your info
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
logrotate with date in filename ptp Linux - Newbie 1 04-14-2011 10:55 AM
Insert date and timestamp Into File name petenyce Linux - Newbie 9 10-13-2005 12:16 PM
adding date to filename (creating a quick screenshot button) toaster.waffle Linux - Software 2 04-27-2005 03:19 AM
Converting the date (not timestamp) mpgram Programming 2 04-18-2004 03:56 PM
how to add date to filename x2000koh Programming 1 07-08-2003 09:44 PM


All times are GMT -5. The time now is 08:02 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration