[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Command touch and irregular file names



On Tuesday 14 August 2007 17:54, - Tong - wrote:
> How to let command touch to work with irregular file names?
>
> In my script I have
>
>  touch -r "$file1" "$file2"
>
> the file1/2 can be anything file, ../path/file, /root/file, etc.
>
> The problem is when file1/2 are irregular file names. E.g., -test.file1/2.
>
> I.e., anyway to make the following touch command works?
>
>  $ touch -r "-test.file1" "-test.file2"
>  touch: invalid date format `est.file2'
>
> FYI, I tried this but didn't work:
>
>  $ touch -r -- "-test.file1" "-test.file2"
>  touch: invalid date format `est.file1'
>
> I think if the touch command uses the standard gnu getopt lib, then
> the above code should work, shouldn't it?

If file1 is to provide the reference timestamp via the -r argument,
try:

   touch -r "$file1" -- "$file2"

--Mike Bird



Reply to: