Sponsored Content
Top Forums Shell Programming and Scripting Shell script for Creating Directory with name as system date Post 91944 by aarora_98 on Tuesday 6th of December 2005 05:19:46 PM
Old 12-06-2005
Shell script for Creating Directory with name as system date

Dear Sir/Madam,

I need a bit of your help. The problem is as follows :

I have to create a directory in unix whose name is that of system date in the dd_mon_yyyy format . I am able to extract a date in required format ina variable , but when i'm using this variable in mkdir it is not creating a directory of that date, rather it is creating the dirictory of the same name as the variable( mkdir accepts a string name for creating directories , but I don't know how to convert date to string using shell scripting). I am writing below the piece of script of what I am doing. Plz correct me where ever possible. i hope to see a nice running solution from your side.

>Today='date +%d_%m_%Y'
>set
>$Today
>mkdir $Today

I hope you will help me.

plz do mail me a solution at EMAIL ADDRESS REMOVED

Thanks in advance.
Arun

Last edited by Perderabo; 12-06-2005 at 09:14 PM.. Reason: Remove email address
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to selectively tar directory based on date

hye everybody :) , i'm new to the scripting world.. hope you guys can help me out with this one.. i'm trying to identify any directory under /tmp/saya that is created more than one day from the current date.. e.g, today is March 14, so any directory that has time stamp March 13 backwards, i... (2 Replies)
Discussion started by: fara_aris
2 Replies

2. Shell Programming and Scripting

Creating date directory and moving files into that directory

I have list of files named file_username_051208_025233.log. Here 051208 is the date and 025233 is the time.I have to run thousands of files daily.I want to put all the files depending on the date of running into a date directory.Suppose if we run files today they should put into 05:Dec:08... (3 Replies)
Discussion started by: ravi030
3 Replies

3. Shell Programming and Scripting

How to increment a user defined date value in the DATE format itself using shell script?

I need to increment a date value through shell script. Input value consist of start date and end date in DATE format of unix. For eg. I need increment a date value of 1/1/09 to 31/12/09 i.e for a whole yr. The output must look like 1/1/09 2/2/09 . . . 31/1/09 . . 1/2/09 . 28/2/09... (1 Reply)
Discussion started by: sunil087
1 Replies

4. Shell Programming and Scripting

Creating a directory if its non-existent within a script

Hi, is there a way to create a directory when its non-existent when trying to move files to this particular folder? Thanks much. (7 Replies)
Discussion started by: ida1215
7 Replies

5. Programming

Script for creating a directory & move the .tif files in it.

Hi Team, I have thousands of TIF files which are converted from PDF. Below is a sample of it. LH9406_BLANCARAMOS_2012041812103210320001.tif LH9406_BLANCARAMOS_2012041812103210320002.tif LH9406_BLANCARAMOS_2012041812103210320003.tif LH9411_ANGENIAHUTCHINSON_2012041812102510250001.tif... (9 Replies)
Discussion started by: paragnehete
9 Replies

6. Homework & Coursework Questions

Creating a .profile, displaying system variables, and creating an alias

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Here is what I am supposed to do, word for word from my assignment page: 1. Create/modify and print a... (2 Replies)
Discussion started by: Jagst3r21
2 Replies

7. UNIX for Dummies Questions & Answers

Creating a directory based on date

I want to create a directory based on date. I do not have date -d command. What I do have is: either use "date" command to get current date or DATE1=$(perl -e 'print scalar(localtime(time - 1 )), "\n";' |awk '{print $2,$3,$5}') |awk '{print $3}'can be modified to produce the desired year.... (3 Replies)
Discussion started by: newbie2010
3 Replies

8. UNIX for Beginners Questions & Answers

Compare date in .txt with system date and remove if it's lesser than system date

Can someone help me with the code wherein there is a file f1.txt with different column and 34 column have expiry date and I need to get that and compare with system date and if expiry date is <system date remove those rows and other rows should be moved to new file f2.txt . I don't want to delete... (2 Replies)
Discussion started by: Stuti
2 Replies

9. Answers to Frequently Asked Questions

Compare date in .txt with system date and remove if it's lesser than system date

I m working on shell scripting and I m stuck where in my .txt file there is column as expiry date and I need to compare that date with system date and need to remove all the rows where expiry date is less than system date and create a new .txt with update. (1 Reply)
Discussion started by: Stuti
1 Replies

10. Linux

How to calculate the quarter end date according to the current date in shell script?

Hi, My question is how to calculate the quarter end date according to the current date in shell script? (2 Replies)
Discussion started by: Divya_1234
2 Replies
Template::Plugin::Date(3)				User Contributed Perl Documentation				 Template::Plugin::Date(3)

NAME
Template::Plugin::Date - Plugin to generate formatted date strings SYNOPSIS
[% USE date %] # use current time and default format [% date.format %] # specify time as seconds since epoch # or as a 'h:m:s d-m-y' or 'y-m-d h:m:s' string [% date.format(960973980) %] [% date.format('4:20:36 21/12/2000') %] [% date.format('2000/12/21 4:20:36') %] # specify format [% date.format(mytime, '%H:%M:%S') %] # specify locale [% date.format(date.now, '%a %d %b %y', 'en_GB') %] # named parameters [% date.format(mytime, format = '%H:%M:%S') %] [% date.format(locale = 'en_GB') %] [% date.format(time = date.now, format = '%H:%M:%S', locale = 'en_GB) %] # specify default format to plugin [% USE date(format = '%H:%M:%S', locale = 'de_DE') %] [% date.format %] ... DESCRIPTION
The "Date" plugin provides an easy way to generate formatted time and date strings by delegating to the "POSIX" "strftime()" routine. The plugin can be loaded via the familiar USE directive. [% USE date %] This creates a plugin object with the default name of '"date"'. An alternate name can be specified as such: [% USE myname = date %] The plugin provides the "format()" method which accepts a time value, a format string and a locale name. All of these parameters are optional with the current system time, default format ('"%H:%M:%S %d-%b-%Y"') and current locale being used respectively, if undefined. Default values for the time, format and/or locale may be specified as named parameters in the "USE" directive. [% USE date(format = '%a %d-%b-%Y', locale = 'fr_FR') %] When called without any parameters, the "format()" method returns a string representing the current system time, formatted by "strftime()" according to the default format and for the default locale (which may not be the current one, if locale is set in the "USE" directive). [% date.format %] The plugin allows a time/date to be specified as seconds since the epoch, as is returned by "time()". File last modified: [% date.format(filemod_time) %] The time/date can also be specified as a string of the form "h:m:s d/m/y" or "y/m/d h:m:s". Any of the characters : / - or space may be used to delimit fields. [% USE day = date(format => '%A', locale => 'en_GB') %] [% day.format('4:20:00 9-13-2000') %] Output: Tuesday A format string can also be passed to the "format()" method, and a locale specification may follow that. [% date.format(filemod, '%d-%b-%Y') %] [% date.format(filemod, '%d-%b-%Y', 'en_GB') %] A fourth parameter allows you to force output in GMT, in the case of seconds-since-the-epoch input: [% date.format(filemod, '%d-%b-%Y', 'en_GB', 1) %] Note that in this case, if the local time is not GMT, then also specifying '%Z' (time zone) in the format parameter will lead to an extremely misleading result. Any or all of these parameters may be named. Positional parameters should always be in the order "($time, $format, $locale)". [% date.format(format => '%H:%M:%S') %] [% date.format(time => filemod, format => '%H:%M:%S') %] [% date.format(mytime, format => '%H:%M:%S') %] [% date.format(mytime, format => '%H:%M:%S', locale => 'fr_FR') %] [% date.format(mytime, format => '%H:%M:%S', gmt => 1) %] ...etc... The "now()" method returns the current system time in seconds since the epoch. [% date.format(date.now, '%A') %] The "calc()" method can be used to create an interface to the "Date::Calc" module (if installed on your system). [% calc = date.calc %] [% calc.Monday_of_Week(22, 2001).join('/') %] The "manip()" method can be used to create an interface to the "Date::Manip" module (if installed on your system). [% manip = date.manip %] [% manip.UnixDate("Noon Yesterday","%Y %b %d %H:%M") %] AUTHORS
Thierry-Michel Barral wrote the original plugin. Andy Wardley provided some minor fixups/enhancements, a test script and documentation. Mark D. Mills cloned "Date::Manip" from the "Date::Calc" sub-plugin. COPYRIGHT
Copyright (C) 2000-2007 Thierry-Michel Barral, Andy Wardley. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin, POSIX perl v5.16.3 2012-01-13 Template::Plugin::Date(3)
All times are GMT -4. The time now is 09:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy