Need help in changing Mod time of a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in changing Mod time of a file
# 1  
Old 09-22-2008
Need help in changing Mod time of a file

I have a file called MasterRECEIVEFranScript. I need to change its modified time to Sep 20 09:34 2008

For this i have tried a command ,but no success

touch -m -t 1222079885 MasterRECEIVEFranScript

-------------------------------------------------------------

Plz help me in this ?

it's giving me time as Oct 11 2013

Last edited by ali560045; 09-22-2008 at 08:04 AM..
# 2  
Old 09-22-2008
Code:
$ ls -lrt shell2.ksh
-rw-rw-r--   1 ppattusa pcfd          71 Jun 10 00:00 shell2.ksh

$ touch -m -t 200809200934 shell2.ksh

$ ls -lrt shell2.ksh
-rw-rw-r--   1 ppattusa pcfd          71 Sep 20 09:34 shell2.ksh

Its working for me. Wat the error you getting...?
# 3  
Old 09-22-2008
The time stamp you are issuing in the -t option looks funky. Try with the format suggested by Palsevlohit_123's example.

Might be better to post a followup rather than edit your original submission, as it's not obvious what you have changed, and/or whether you are responding to the questions asked in followups.
# 4  
Old 09-22-2008
look 1222079885 is the epoch time which corresponds to Sep 20 09:34

if you use command
perl -le 'print scalar localtime(1222079885);'

It's giving the below ouptput
Mon Sep 22 05:38:05 2008

But when i m using this with the below command it's gives me time as Oct 11 2013

touch -m -t 1222079885 MasterRECEIVEFranScript
# 5  
Old 09-22-2008
Touch accepts the -t argument in the form [[CC]YY]MMDDhhmm[.SS], not the epoch time. Read of the manpage of touch!
# 6  
Old 09-22-2008
Thanks a lot evrybody i got it using

touch -m -t 200809200934

command.

I was just wondering can we do it through EPOCH time.

Thanks a lot everybody
# 7  
Old 09-23-2008
You can easily convert epoch to human-readable and/or the format expected by touch -t with Perl.

Code:
touch -m -t $(perl -e '@l=localtime(shift);
  printf "%02i" x 5 . "\n", $l[5]+1900, @l[4,3,2,1]' 1222079885) shell2.ksh

If your shell is very old, you'll need to use `...` instead of $(...), with grave accents / backticks (ASCII 96; not regular straight quotes!) around the Perl command.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Changing only time zone file not the timezone without reboot

Hello all, I just want to update the timezone file with new file to update the time, so the zone in /etc/TIMEZONE will be the same but the file it refers to will be changed, and the local time should be changed, can this take effect without rebooting Solaris 10? (9 Replies)
Discussion started by: Amr.Es
9 Replies

2. Shell Programming and Scripting

changing a file when the inode modified time of the other file changes

i have a requirement where i needed to change variable values in a properties file(first file) whenever there is change to Release details file(second file). My question is do i have to create a daemon process that always checks the modified time/inode change of the second file and then change the... (1 Reply)
Discussion started by: saikiran_1984
1 Replies

3. Shell Programming and Scripting

Last modified time of the folder is changing when I view the file inside the directory

Hi., Last modified time of the folder is changing when I view the file inside the directory. Here is the test on sample directory. I believe that ls -l commands gives the time detail w.r.t last modified time. Pl. suggest. bash-3.2$ mkdir test bash-3.2$ cd test bash-3.2$ touch myfile.txt... (2 Replies)
Discussion started by: IND123
2 Replies

4. Shell Programming and Scripting

Changing File Time Stamp (Bash Script)

I need some help recovering from a "slight" screwup. We just moved 3 TB of data from one RAID Array to another. Low lever archive files. This was done with a regular cp (for some reason) and now we have lost all the timestamps on the files, and we urgently need to get the timestamps back on these... (7 Replies)
Discussion started by: chj
7 Replies

5. Shell Programming and Scripting

Why does the 'pid' keep changing every time?

HI I checked the pid of a process on my machine using this command. ps -ef | awk '/process_name/{ print $2 }' I get the result as 12245 I check it again after 2 mins, I get the result as 12264 I check it again after 2 mins, I get the result as 12289 It keeps on this. How does this pid... (4 Replies)
Discussion started by: ss3944
4 Replies

6. AIX

changing server time

Hi all, we have IBM- AIX 5.2 operating system on that we have our oracle production database and there is daily crontab script for backup. my boss told me to change the server time.if i change the server time by root user does it give problem to any application or script which are... (2 Replies)
Discussion started by: younusdba
2 Replies

7. Shell Programming and Scripting

changing modified time

How to change the modified time of a file to any specified time. ls -ltr drwxr-xr-x 2 pipe pipe 4096 Jun 10 10:33 coredump_06062008 ---------------------------------------------------------------------- here file coredump_06062008 last modified time is Jun 10 10:33 and i... (1 Reply)
Discussion started by: ali560045
1 Replies

8. UNIX for Dummies Questions & Answers

How to MV without changing Time Stamp

Hi, I need to move the set of files, and it should be same time stamp as previous. How to do this? (3 Replies)
Discussion started by: redlotus72
3 Replies

9. Shell Programming and Scripting

retain create/mod date and time of files

Hi, I have a requirement by which I need to take a snapshot of a certain directory of a certain types of files into a target directory within the same server (HP-UX 9000). The problem is that the files created in the target directory has the date and time of when the files were copied over. ... (5 Replies)
Discussion started by: jerardfjay
5 Replies
Login or Register to Ask a Question