On Fri, Oct 04, 2002 at 01:17:21PM +0200, Van Den Abeele Kristof wrote:
> A want to create a file "10_Oct_2002.out"  ( based on todays date )
> How can I do this using the date command , pipes , redirections & touch command.
> 
> I'v tried things like : # touch < date +%m_%b_%y.out 
>                               # several other combinations 
> 
> But I don't seem to find the magic combination
> 

You've very nearly got it right, but you're missing a critical part
of the shell syntax you need.

What you've told touch to do, above, is to accept on its standard input
the name of the file to touch.

But many commands don't work that way, they want the file name on 
their commandline.

You can do that in any (AFAIK) Unix shell (including bash) by enclosing
the command in (what is often called) backtics, this character: `
It's NOT the apostrophe ('), but its approximate mirror image. 

This takes the standard output of whatever is enclosed inside it
and substitutes it into the commandline of the preceding command.
So, to do what you want, you should do:

        touch `date +%m_%b_%y.out`
-- 
---- Fred Smith -- [EMAIL PROTECTED] -----------------------------
   "For the word of God is living and active. Sharper than any double-edged 
   sword, it penetrates even to dividing soul and spirit, joints and marrow; 
              it judges the thoughts and attitudes of the heart."  
---------------------------- Hebrews 4:12 (niv) ------------------------------



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to