LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  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: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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



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
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

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 05:54 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