Computing.Net > Forums > Unix > script to update file timestamp

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

script to update file timestamp

Reply to Message Icon

Name: vish
Date: July 19, 2006 at 07:41:31 Pacific
OS: sun os
CPU/Ram: sun4u
Product: ultra-60
Comment:

hi,

I am trying to write a unix script that recursively goes into each directory and 'touches' the file to update the time stamp.....any help on how to go about it is appreciated..



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: July 19, 2006 at 10:02:02 Pacific
Reply:


I'm not near a unix box, so this is:

# untested
find /mydir -type f -print|while read myfile
do
touch myfile
done


0

Response Number 2
Name: nails
Date: July 19, 2006 at 15:59:16 Pacific
Reply:

Sorry, but I corrected a syntax error:

I'm not near a unix box, so this is:
# untested
find /mydir -type f -print|while read myfile
do
touch $myfile
done


0

Response Number 3
Name: ghostdog
Date: July 19, 2006 at 22:14:40 Pacific
Reply:

find /mydir -type f |xargs touch


0

Response Number 4
Name: vish
Date: July 24, 2006 at 08:57:19 Pacific
Reply:

I am new to unix, I saved the file as test.sh and changed permissions using chmod 777 test.sh. When i try to run using ./test or test I keep getting the message "command not found"...wht am i doing wrong here?


0

Response Number 5
Name: nails
Date: July 24, 2006 at 11:46:56 Pacific
Reply:

I'm guessing that the directory where script test.sh resides isn't in your PATH. If your current directory is the directory where test.sh resides and it still doesn't work, try this:

./test.sh

If you want unix to search your current directory, append a period to end of PATH:

PATH=$PATH:.
export PATH

I must warn you about the security considerations of doing this - especially if you are the root user.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Renaming file using Perl unix shellscripting



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: script to update file timestamp

script to move file www.computing.net/answers/unix/script-to-move-file/4235.html

Script to scan files for a string www.computing.net/answers/unix/script-to-scan-files-for-a-string/7532.html

Script to process/search a csv file www.computing.net/answers/unix/script-to-processsearch-a-csv-file/5115.html