1830952 Members
2024 Online
110017 Solutions
New Discussion

Crating file with date

 
SOLVED
Go to solution
jayachandran.g
Regular Advisor

Crating file with date

Hi all

How to create a file with todays dat as a name of it.

20050531.txt

I have searched in the forum but i have not answer for this.
4 REPLIES 4
Leif Halvarsson_2
Honored Contributor
Solution

Re: Crating file with date

hi,
Look at the man page for date.
ex:
file=$(date +%Y%m%d)
>$file
jayachandran.g
Regular Advisor

Re: Crating file with date

Hi Leif

i was not noticed that +. sorry
Gopi Sekar
Honored Contributor

Re: Crating file with date


use like this:

file_name="`date +%Y%m%d`.txt"

## now do what you want in $file_name

Never Never Never Giveup
Joaquin_13
Advisor

Re: Crating file with date

Hi,

you can just simply invoke this command when creating a new file using the filename format you prefer

$ cat > date +%Y%m%d.txt -- if this doesn't the other way around is to set an variable in your env. by simply invoking

$ export =`date +%Y%m%d`
$ cat > $.txt

hope this can help..