Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 01-21-2009, 05:30 AM   #1
LQ Newbie
Registered: Jan 2009
Posts: 1

Rep: Reputation: 0
Date wise Folder name


I am a newbie to Linux. I am using RH Enterprise edition.

I am writing a Script which will create folder everyday with the date as the folder name. For example: 20090120 or 20090119 etc. And then I will save some file in that folder, Zipped that folder and then mailed that zipped folder to some receipt's.

But every time I create a folder there is some garbage at the end of the folder name. For example: 20010120? or 20090120??. So when I try to enter or zip that folder it is giving error such as ...... No File Found / No such Folder....etc. So I am not able to work with that created folder or neither I can enter that folder.

Another this is that when I run the mkdir command from command prompt it is working fine. only problem is running mkdir cmd from Script.

my script is like that.......

Date=`date +%F -d '-1 day'`
mkdir /root/xyz/$Date

Can any body tell me what to do..........

Old 01-21-2009, 01:13 PM   #2
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
It works fine for me at the bash command line:
tred@vaio:~$ Date=`date +%F -d '-1 day'`
tred@vaio:~$ echo $Date
tred@vaio:~$ mkdir ~/test/$Date
tred@vaio:~$ ls test
If you are writing a script, what editor did you use to write the script on? If it was a windows editor, try writing it using a linux editor (and do NOT just copy&paste !).

Reason: linux and windows use different end-of-line markers.

Read up on dos2unix and unix2dos

Don't forget that most linux scripts should start with the line
so you know you'll be using the bash shell to interpret the script..

Last edited by tredegar; 01-21-2009 at 01:15 PM.


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
copy folder/files according to modification date bkcreddy17 Programming 14 10-15-2008 08:24 PM
Squid Access Logs date wise the_gripmaster Linux - Software 1 10-03-2007 10:38 PM
digikam 0.9.1 automatically create folder by date ToK Linux - Software 0 05-12-2007 04:12 AM
delete files date wise hardeep_ubhi Linux - General 1 11-16-2004 03:07 AM
bandwidth allocation by user wise and ip wise basbosco Linux - Networking 1 11-12-2003 03:54 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration