need to create a file with its name having system date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need to create a file with its name having system date
# 8  
Old 10-18-2006
Following code crates a file with systemdate followed by filename

Code:
SYSDATE=`date +%d"-"%m"-"%y":"%H%M`
touch filename$SYSDATE


this code deletes the file which are older then 5 days

Code:
MYDIR=/home/sri/yourdir #give your desired directory
cd $MYDIR
find . -type f -name "*.*" -mtime +5 -exec rm {} \;

go thourgh this...if any assistant pls let me know...
# 9  
Old 10-18-2006
Hi All,

My question is involved in this same question :

errdate=$(date +%m/%d-%H:%M:%S)
echo $errdate


I get the date in the numeric....
my requirement is i want to get Month as month name.

For this i tried by the following way :

errdate=$(date +%b %d %H:%M:%S)
echo $errdate


i was getting the output as 'Oct', nothing else.

but i want Oct 18 07:49:57 as output, plz help me.

Regards,
Ravi.
# 10  
Old 10-18-2006
Quote:
Originally Posted by rkrgarlapati
Hi All,

My question is involved in this same question :

errdate=$(date +%m/%d-%H:%M:%S)
echo $errdate


I get the date in the numeric....
my requirement is i want to get Month as month name.

For this i tried by the following way :

errdate=$(date +%b %d %H:%M:%S)
echo $errdate


i was getting the output as 'Oct', nothing else.

but i want Oct 18 07:49:57 as output, plz help me.

Regards,
Ravi.
Hi
Use this:
Code:
errdate=$(date +%b" "%d" "%H:%M:%S) 
echo $errdate

# 11  
Old 10-18-2006
Thanks Indalecio Smilie
I got my wanted solution.
# 12  
Old 10-18-2006
Try:
Code:
errdate=$(date +%b" "%d" "%H:%M:%S)

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

3. Shell Programming and Scripting

Compare the system date with date from a text file

I get the date that's inside a text file and assigned it to a variable. When I grep the date from the file, I get this, Not After : Jul 28 14:09:57 2017 GMT So I only crop out the date, with this command echo $dateFile | cut -d ':' -f 2,4The result would be Jul 28 14:57 2017 GMT How do I... (3 Replies)
Discussion started by: Loc
3 Replies

4. Shell Programming and Scripting

Replacing Date in the file with Create date and timestamp

Hello, I have files that with a naming convention as shown below. Some of the files have dates in the file name and some of them don't have dates in the file name. imap-hp-import-20150917.txt imap-dell-gec-import-20150901.txt imap-cvs-import-20150915.txt imap-gec-import.txt... (8 Replies)
Discussion started by: Saanvi1
8 Replies

5. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

6. UNIX for Dummies Questions & Answers

For create file system.

How many ways and how we can create unix file system in sun solaris? (1 Reply)
Discussion started by: anupdas
1 Replies

7. Shell Programming and Scripting

how to create file.txt and add current date in file content

Hey guy, how to make bash script to create foo.txt file and add current date into file content and that file always append. example: today the script run and add today date into content foo.txt and tomorrow the script will run and add tomorrow date in content foo.txt without remove today... (3 Replies)
Discussion started by: chenboly
3 Replies

8. UNIX for Dummies Questions & Answers

How to create a new file system

Is there any URL or procedure to create a new file system on solaris 8/9/10.. (3 Replies)
Discussion started by: tintedwindow
3 Replies

9. SCO

create a new file system

I have just installed 5.0.7 of openserver and forgot to create a /u filesystem. I have a root filesystem that takes up most of the hard disc space and I want to reduce the size of that and create a /u. I have tried divvy amd mkdev fs but to no avail. Could somebody give me some idea as to how I... (2 Replies)
Discussion started by: rongrout
2 Replies

10. UNIX for Dummies Questions & Answers

file date vs. system date

Hey all, I know there was a post on here at one point about how to get file properties such as create time and such, but I've searched high and low without success. What I need to do is create a script that runs daily that will expire or remove files that are older than 1 month, or possibly a... (8 Replies)
Discussion started by: ober5861
8 Replies
Login or Register to Ask a Question