How to create filename with date and not have blanks

How to create filename with date and not have blanks

Post by William Nu » Wed, 25 Oct 1995 04:00:00



I want to create a file name concatenated with `date`

example:
cat > approve_`date`.ksh <<-EOF
whatever
you
like
EOF

my resulting file name is approve_Tue Oct 24 09:20:22 CDT 1995.ftp
Being very new to UNIX I tried using sed, ex, and awk to modify the filename;
before knowning these modify file content (let me know if this is wrong).

Any help is appreciated,
Willam

 
 
 

How to create filename with date and not have blanks

Post by Shawn D. McPe » Wed, 25 Oct 1995 04:00:00


: I want to create a file name concatenated with `date`
:  
: example:
: cat > approve_`date`.ksh <<-EOF
: whatever
: you
: like
: EOF
:  
: my resulting file name is approve_Tue Oct 24 09:20:22 CDT 1995.ftp
: Being very new to UNIX I tried using sed, ex, and awk to modify the filename;
: before knowning these modify file content (let me know if this is wrong).

What I would do is something like this:
cat > approve_`date +%d%b%y`.ksh <<-EOF
...

 
 
 

How to create filename with date and not have blanks

Post by Mark Jah » Wed, 25 Oct 1995 04:00:00



>I want to create a file name concatenated with `date`

>example:
>cat > approve_`date`.ksh <<-EOF
>whatever
>you
>like
>EOF

>my resulting file name is approve_Tue Oct 24 09:20:22 CDT 1995.ftp
>Being very new to UNIX I tried using sed, ex, and awk to modify the filename;
>before knowning these modify file content (let me know if this is wrong).

  Try something like:
%cat > approve_`date '+%y%m%d'`.ksh <<-EOF
whatever
you
like
EOF

  The man pages on date explains it pretty well.
------------------------------------------------------------
Shaw's Principle:
        Build a system that even a fool can use, and only a fool will
want to use it.
------------------------------------------------------------


        MSMAIL                          Voice (612) 687-2817

------------------------------------------------------------

 
 
 

How to create filename with date and not have blanks

Post by Goran Larss » Wed, 25 Oct 1995 04:00:00




> I want to create a file name concatenated with `date`
> cat > approve_`date`.ksh <<-EOF
> my resulting file name is approve_Tue Oct 24 09:20:22 CDT 1995.ftp

If the date program in your version of UNIX has the "+format" option,
then try this:

 cat > approve_`date '+%y%m%d%H%M%S'`.ksh <<-EOF

or

 cat > `date '+approve_%y%m%d%H%M%S.ksh'` <<-EOF

Do "man date" for description of other %-and-letter combinations.

Btw, do you have permission from our company to use approve
in a filename?    :-)

--
 Goran Larsson              Phone: +46 13 299588  FAX: +46 13 299022
 Approve AB                        +46 589 12810       +46 589 16901

           I was an atheist, until I found out I was God.

 
 
 

How to create filename with date and not have blanks

Post by Jan de Hee » Thu, 26 Oct 1995 04:00:00



>I want to create a file name concatenated with `date`

>example:
>cat > approve_`date`.ksh <<-EOF
>whatever
>you
>like
>EOF

>my resulting file name is approve_Tue Oct 24 09:20:22 CDT 1995.ftp
>Being very new to UNIX I tried using sed, ex, and awk to modify the filename;
>before knowning these modify file content (let me know if this is wrong).

>Any help is appreciated,
>Willam


Hello William,

Before you want to do this, first read the manual pages about date. (In UNIX the
command is: man date) I frequently use date as well, but I do it this way

   FIL="filename.`date +%d%m%y`"
   command > $FIL

I hope this helps.

Greetings

Jan

--
      #  ##  #  #  |  Philips C&P TS-NSD Multi Protocol Network
      # #  # ## #  |  VA-130, PO Box 218, 5600 MD Eindhoven
   #  # #### # ##  |  Tel: (+3140-7)55497, Fax: (+3140-7)82900

 
 
 

How to create filename with date and not have blanks

Post by Floyd Davids » Thu, 26 Oct 1995 04:00:00





>>I want to create a file name concatenated with `date`
...
>cat ? approve_`date | tr -d " "`.ksh <<-EOF
>[eliminates spacing]

>cat > approve_`date | tr " " "_"`.ksh <<-EOF
>[replaces spaces with underscores]

Read the man page on "date", and take your pick of formatting.
I prefer this one:

     approve_`date +%y%m%d`.skh <<-EOF
     ...

Which will give a file name "approve_951025.ksh".  The format
string "+%y%m%d%H%M%S" extends that down to the second.

  Floyd
--

 
 
 

How to create filename with date and not have blanks

Post by Reece Kimball Ha » Fri, 27 Oct 1995 04:00:00


William> I want to create a file name concatenated with `date`
William> example:
William> cat > approve_`date`.ksh <<-EOF
...
William> Being very new to UNIX...

Welcome to Unix.  The most immediate source of info about commands are
the man pages.  You can access them with the man command, as in:
$ man date
($ is your prompt)
Of course, man man will tell you how to use man.  Of particular
interest is
$ man -k keyword
which searches for man pages by keyword.

In your case, man date will tell you that date takes optional
arguments, one of which is a format string.  Try
$ date +%y%m%d
for YYMMDD format dates.

--

Biophysics & Biochemistry           | WWW:   http://dasher.wustl.edu/~reece/
Washington Univ. School of Medicine | Phone: (314) 362-4198 (lab)  -7183 (fax)
St. Louis, Missouri  (USA)          | PGP public key available by finger & WWW

 
 
 

How to create filename with date and not have blanks

Post by Kevin Dar » Fri, 27 Oct 1995 04:00:00




>I want to create a file name concatenated with `date`

>example:
>cat > approve_`date`.ksh <<-EOF
>whatever
>you
>like
>EOF

>my resulting file name is approve_Tue Oct 24 09:20:22 CDT 1995.ftp
>Being very new to UNIX I tried using sed, ex, and awk to modify the filename;
>before knowning these modify file content (let me know if this is wrong).

Did you look at the man page for the "date" command itself? "date" is quite
flexible about formatting its output. For instance, if you wanted the default
output, but with spaces replaced with underscores, you could just say

        date '+%a_%b_%e_%T_%Z_%Y'

which, right this moment, gives me

        Thu_Oct_26_18:12:47_EDT_1995

Or, you can format it any number of other ways...

--------------------------------------------------------------------------------


Voice: (810) 759-7140     NeXTMail     | Chrysler Corporation
Fax:   (810) 758-8173     welcome)     | Center Line, Michigan, I/S Complex
--------------------------------------------------------------------------------

 
 
 

1. Create Files w/date included in filename?

I am new to unix shell scripts and when reviewing the man page,
I didn't find a very good description of how to create a file
with a date included in the file name.

Ie.

i want to create a file with the following file name structure:

XXmmdd01.dat

where XX = two  constant characters

      mm = month

      dd = day

      01 = constant numbers

I know you can date +%m%d to get the month and day but, how do
you put it in the middle of the other characters?

Any help would certainly be appreciated.


2. booting problem, revised

3. Capturing an a filename that contains the month/date in filename ie fileMMDD

4. Script or software to add many, many users

5. renaming files from filename to filename-date

6. 3com 3c900, Redhat 6.2 and @home - Will it work?

7. having a date automatically appened to a date?

8. KDE 1.0 to 1.1pre2 upgrade

9. Y2K Server bug not NcFTP and Y2K issues on filename dates

10. Creating SSA RAID after having created Vol.Grps

11. Using tar with filenames that have blank spaces

12. System date and file dates not showing in same time zone

13. Changing Filenames with Blank spaces.