Changing time and date on files

Changing time and date on files

Post by Marvin Franke » Thu, 15 Nov 2001 10:41:23



I want to use touch  or  any available  tool on Solaris 7 to change the time
and date
on  all files in a source  directory and its  subdirectory in  one shot.

Any help appreciated.

 
 
 

Changing time and date on files

Post by Logan Sh » Thu, 15 Nov 2001 10:50:35




>I want to use touch  or  any available  tool on Solaris 7 to change the time
>and date
>on  all files in a source  directory and its  subdirectory in  one shot.

Does "one shot" mean one executable invocation?  It's going to have to
be separate system calls, I think.

Anyway, I'd use Perl.  This is basically equivalent to "touch *.c *.h":


You can use your own value for "$now" instead of setting it to the
current time, although it's a bit of a bad user interface since you
have to supply a time_t.  If you want, you can read the time from
another file by using the Perl stat() function.  I don't know exactly
what your goal is...

  - Logan
--
"In order to be prepared to hope in what does not deceive,
 we must first lose hope in everything that deceives."

                                          Georges Bernanos

 
 
 

Changing time and date on files

Post by Alberto da Silv » Thu, 15 Nov 2001 20:33:24


touch `find .`
or
find . -exec touch {} \;

> I want to use touch  or  any available  tool on Solaris 7 to change the time
> and date
> on  all files in a source  directory and its  subdirectory in  one shot.

> Any help appreciated.

 
 
 

Changing time and date on files

Post by Logan Sh » Fri, 16 Nov 2001 00:41:49






>>I want to use touch  or  any available  tool on Solaris 7 to change the time
>>and date
>>on  all files in a source  directory and its  subdirectory in  one shot.

>Does "one shot" mean one executable invocation?  It's going to have to
>be separate system calls, I think.

>Anyway, I'd use Perl.  This is basically equivalent to "touch *.c *.h":



Now that I've posted this, I realize you can do it with "touch", so
using Perl is pointless and unnecessary.  I took the question to mean
that "touch" couldn't do it, when in fact it can, and more conveniently
and efficiently than Perl in most cases.

The original poster's question is apparently how to give multiple
filenames in the current directory and a subdirectory to a command,
in which case the answer is something like this:

    # make the shell build the list of files
    touch *.c subdir/*.c

or (as someone else has already said) this:

    # make find build the list of files, and make the shell put it
    # on touch's command line
    touch `find . -type f -name '*.c' -print`

or this:

    # make find build the list of files, and make xargs put it
    # on touch's command line
    find . -type f -name '*.c' -print | xargs touch

They each have their own limitations.

  - Logan
--
"In order to be prepared to hope in what does not deceive,
 we must first lose hope in everything that deceives."

                                          Georges Bernanos

 
 
 

1. date/time of a file compare with current date/time

Hi,

I hope i can drop my question about Linux shell programming here?

I'm writing a script in bash to find files. I'm using the slocate
programm, which is being runned every hour using a cron job, to create
it's database.

Now i want to know how long it is ago that the database has been
recreated. Zo i need to check the date and time from that file and
compare it with the current date and time. I know there must be easy to
do but i can't find the trick to do it.

Maikel van Gorkom

Sent via Deja.com http://www.deja.com/
Before you buy.

2. FreeBSD for the desktop

3. Archiving files in "date folders" based on date and time file generated

4. Trouble with CGI (POSTing) w/ Apache

5. Changing File Modified Time/Date Stamp

6. FS: RS/6000 Systems.

7. Backup by file w/o changing access date/time

8. Errors with Samsung IDE drive

9. changing file date/time from C program

10. Samba / NT file date/time changes

11. Changing File Modified Time/Date Stamp

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

13. run time date and syslog date/time conflict