Changing File Modified Time/Date Stamp

Changing File Modified Time/Date Stamp

Post by Hon-Chi N » Thu, 25 Feb 1999 04:00:00





> # Hi
> #
> # How can I change the modified date/time of a file to a past/future
> # time?  Is there a shell command or utility available in Solaris or HP-UX
> # to do that?  I only know "touch" that updates the file modified

> Then you don't know touch. :)

> Look at the man page and pay attention to the -t flag.

Well, maybe I don't know how our sys admin installs it.  :^)FYI, I'm using
Solaris 2.5.1

  > man touch
    ...
  SYNOPSIS
       touch [-acm] [-r ref_file] file...
       touch [-acm] [-t time] file...
       touch [-acm] [date_time] file...

But
  > touch -t 01011200 MyFile
  usage: touch [-amcf] file ...

  > which touch
  /usr/bin/touch

If
  > man -s 1b touch
    ...
  SYNOPSIS
       /usr/ucb/touch [-acfm] file...Obviously, my "touch" command and its
manpage don't match.  :^(

Which is the default "touch" in Solaris 2.5.1?  Where can I  get the "touch"
for Solaris 2.5.1 that allows me to set a specific time/date stamp, as
described in the manpage?

Quote:> # date/time to the current time only, not to a specific past/future time.
> #
> # Hon-Chi

Hon-Chi
 
 
 

Changing File Modified Time/Date Stamp

Post by Nick Wag » Thu, 25 Feb 1999 04:00:00



> Well, maybe I don't know how our sys admin installs it.  :^)FYI, I'm
> using Solaris 2.5.1

So am I.

Quote:>   > man touch
>     ...
>   SYNOPSIS
>        touch [-acm] [-r ref_file] file...
>        touch [-acm] [-t time] file...
>        touch [-acm] [date_time] file...

Yeah. That's what I get.

Quote:> But
>   > touch -t 01011200 MyFile
>   usage: touch [-amcf] file ...

Nope. Don't get the usage message, but...

ls -l MyFile
-rw-rw-r--   1 bonzo    mygroup        0 Jan  1 12:00 MyFile

Quote:>   > which touch
>   /usr/bin/touch

which touch
/bin/touch

BUT...

ls -ld /bin
lrwxrwxrwx   1 radix    radix         9 Sep 20  1996 /bin -> ./usr/bin/

so /bin/touch is identical to /usr/bin/touch

Quote:> If
>   > man -s 1b touch
>     ...
>   SYNOPSIS
>        /usr/ucb/touch [-acfm] file...Obviously, my "touch" command and
> its manpage don't match.  :^(

Looks like your sysadmin has stuck the UCB touch in your bin directory.
That may be an installation option. You will have to speak to them.

--

Software Project Manager                  Science Park, Milton Rd,
Tel: +44(0)1223 420414 (ext 213)          Cambridge, CB4 0FY, UK.
Fax: +44(0)1223 420044                    http://www.laser-scan.com/
Opinions expressed are attributable to me, not my employer.

 
 
 

Changing File Modified Time/Date Stamp

Post by pooshoote » Fri, 26 Feb 1999 04:00:00


Quote:> so /bin/touch is identical to /usr/bin/touch

Yup, cos /bin is a link to /usr/bin!  This holds true on most UNIX's!
Well, at least Solaris, HP-UX, IRIX, Digital from what I know.  I think
that at least HP have plans to obliterate this link in future releases so
one should always refer to /usr/bin in scripts, as opposed to /bin.  A bit
off the topic but worth mentioning.

AK

 
 
 

Changing File Modified Time/Date Stamp

Post by Suds » Fri, 26 Feb 1999 04:00:00


Hows about 'touch -m -t <timestamp> <file>'. It would appear
that you need to tell touch whether to modify the accessed date,
created date, or modified date, as well as the desired timestamp.



> > # Hi
> > #
> > # How can I change the modified date/time of a file to a past/future
> > # time?  Is there a shell command or utility available in Solaris or HP-UX
> > # to do that?  I only know "touch" that updates the file modified

> > Then you don't know touch. :)

> > Look at the man page and pay attention to the -t flag.

> Well, maybe I don't know how our sys admin installs it.  :^)FYI, I'm using
> Solaris 2.5.1

>   > man touch
>     ...
>   SYNOPSIS
>        touch [-acm] [-r ref_file] file...
>        touch [-acm] [-t time] file...
>        touch [-acm] [date_time] file...

> But
>   > touch -t 01011200 MyFile
>   usage: touch [-amcf] file ...

>   > which touch
>   /usr/bin/touch

> If
>   > man -s 1b touch
>     ...
>   SYNOPSIS
>        /usr/ucb/touch [-acfm] file...Obviously, my "touch" command and its
> manpage don't match.  :^(

> Which is the default "touch" in Solaris 2.5.1?  Where can I  get the "touch"
> for Solaris 2.5.1 that allows me to set a specific time/date stamp, as
> described in the manpage?

> > # date/time to the current time only, not to a specific past/future time.
> > #
> > # Hon-Chi

> Hon-Chi