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
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 12:01 PM
calculate the date of next satureday of current date. rinku Shell Programming and Scripting 1 02-27-2008 04:40 PM
Get date and time for past 1 hour from current date spch2o Shell Programming and Scripting 4 12-21-2007 05:55 AM
File date vs Current date trexlim Shell Programming and Scripting 4 05-04-2007 06:35 PM
I want to get day from the current system date gopskrish UNIX for Dummies Questions & Answers 2 06-24-2005 06:52 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-24-2005
Registered User
 

Join Date: Oct 2005
Posts: 1
get current system date

How do I create a shell script that would get the current system date in format of yyyymmdd and use that result to concatenate it to a filename that it would look like this: sample20051024.dat

Code:
example
--------
current system date: 24-Oct-2005
filename: sample.dat

when the shell script run it now becomes sample20051024.dat
Thanks.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-24-2005
Registered User
 

Join Date: Nov 2001
Location: Flint, MI
Posts: 164
Did you check the FAQ section? I believe this has been answered there.
http://www.unix.com/answers-frequently-asked-questions/
Reply With Quote
  #3 (permalink)  
Old 10-24-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,322
Assuming that you are accepting the system date and the filename from the user, you can use this:
Code:
#!/bin/ksh

oldIFS=$IFS
IFS=$IFS.-
echo "Enter system date: \c"
read year month day
echo "Enter filename: \c"
read fname ext

echo $fname$year$month$day.$ext

IFS=$oldIFS
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:24 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0