ZTree.com  | ZEN  | About...  

 Index   Back

touch as well - how does?   [Help!]

By: Ron Metzger       
Date: Mar 16,2018 at 14:39
In Response to: touch as well - how does? (Ben Kent)

> > Hartmut
> Ben

> > > copy /b name.ext,,+
> >
> > Ben, what do the two commas mean?
> > I guess they are delimiters like space, so the 2nd arg is empty.
> >
> > How is the single '+' (then 3rd arg) interpreted by CMD ?

All arguments are 'interpreted' by cmd.exe

>
> No idea of the details, it's just a very old DOS trick I learnt years
> ago, which is was ported to cmd.exe.
>
> So I get out my ring bound IBM DOS 3.20 manual and have a read, from
> the days when they made proper manuals.

I think dating back to DOS v2.x where similar and nearly unreadable syntax was used in Unix, certain command line 'features' were incorporated.

'then 3rd arg' is implicitly defined. But to see it, you have to know about the explicit (non-)white space character "," interpreted as a white space. Two commas next to each other makes cmd.exe interpret the missing second arg (Destination file) as the same as the first arg (Source file).

"+" is documented in the Copy command, as Concatenate (multiple) files as the source, with the result in the destination. Used after the ,, this is 'interpreted' recursively as Concatenate the Source with the Source, and create the Destination using the Source name.

Complicated? (In my humble opinion, yes.)

Here is the equivalent command in a more readable syntax

copy /B NewFile.txt + NewFile.txt NewFile.txt

copy /B NewFile.txt,,+

could be read as 'Concatenate Source file to itself, and create a Destination file by the same name.'

Finally, /B (or Binary copy) in the copy command simply says "ignore and characters in the copy stream (which normally indicates the default end of copy in identified standard ascii text files). XCopy and all other copy commands that I know of, assume Binary mode copy.

> So I have a test (on Win 8.1), all three of these change the date and
> time, so it's the "+" with no second or output file that is important.
> copy /b name.ext,,+
> copy /b name.ext+,,
> copy /b name.ext+

Yes many variations are available. Unfortunately, not reliable in my opinion.

For instance, I find that these commands do not work always when 'copying' to some network drives, (SAMBA based) from my Windows 10 system.

> >
> > I tried this and noticed that this command does _not set the A
> > attribute on the touched file! Surprising...
>
> Yes in some ways, but the contents have not been changed, only the
> metadata.

The Attribute IS metadata and should have changed. Interesting.


In my humble opinion, redirection is more reliable.

Try

echo( 1>NUL 2>name.ext

Simpler to read and understand.

Ron Metzger

253 views      
Thread locked
 

Messages in this Thread

 
94,650 Postings in 11,937 Threads, 348 registered users, 19 users online (0 registered, 19 guests)
Index | Admin contact |   Forum Time: Dec 9, 2019 - 6:16 pm EST  |  Hits:29,383,996  (2,831 Today )
RSS Feed