extract last modified time of file in form of YYYYMMDD


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting extract last modified time of file in form of YYYYMMDD
# 1  
Old 05-27-2008
extract last modified time of file in form of YYYYMMDD

Hi All,

I want to extract last modified, seen in ls -l command, of a file and then convert it into "YYYYMMDD" format.

Any help regarding would be helpful

Thanks in advance...
# 2  
Old 05-28-2008
try this:
Code:
stat -c '%y' filename | cut -d ' ' -f1 | sed -e 's/-//g'

# 3  
Old 05-28-2008
I couldn't find "stat" in solaris - what is the path? Btw, since I'm learning python Smilie

File:
Code:
 Directory of C:\Tmp

05/28/2008  01:46 PM                 5 abcd

Code:
print "%04d%02d%02d\n" % time.localtime(os.stat("abcd")[-2])[0:3]

Should work in Windows & Unix/Linux provided you have python installed Smilie
# 4  
Old 05-28-2008
Quote:
Originally Posted by Yogesh Sawant
try this:
Code:
stat -c '%y' filename | cut -d ' ' -f1 | sed -e 's/-//g'


Hi

I dont find "stat" in IBM AIX
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to change modified time of a file

A files last modified time is like 03/02/2012 xx:xx:xx So what would be the command to convert the last modified in the given signature Thanks for giving time and replying..:) (2 Replies)
Discussion started by: ezee
2 Replies

2. Shell Programming and Scripting

Run a script when a file is modified/time stamp changed

Hi, I need to run a script file which uses a file and that file is modified as and when some alarms generated, it is not based on any fixed time period.. it may be modified even once in a minute for some time and once in 30 min or once in 20 min. Hence i need to watch for the timestamp change of... (3 Replies)
Discussion started by: aemunathan
3 Replies

3. Shell Programming and Scripting

Filter date and time form a file using sed command

I want to filter out the date and time from this line in a file. How to do this using sed command. on Tue Apr 19 00:48:29 2011 (12 Replies)
Discussion started by: vineet.dhingra
12 Replies

4. 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

5. UNIX for Advanced & Expert Users

Finding the modified date time of a file

Hi, I am new bie to Unix. Might be a simple question I am asking. I want to find the last modified time of a file and find the difference between the currrent time and the last modified time. Appreciate, if someone can throw some light on what commands can be used. Cheers, James (2 Replies)
Discussion started by: JamesJoe
2 Replies

6. 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

7. Shell Programming and Scripting

Reg file modified time

Hi, I have modified one file today. So if i give `ls -lrt filename` command it will show the current modified time. But i wanted to know what is the previous modified time for this file Is there any way to find this Thanks, Puni (3 Replies)
Discussion started by: puni
3 Replies

8. Shell Programming and Scripting

How to extract visually blank lines form the file

Hi, Could some one help me to get rid of visually blank lines from a file using shell or awk or sed (on Solaris machine)? When I use grep grep -v ^$ inputfile >outputfile it removes some blank lines.. but it seems some tab plus space balnk lines remains. thaen I used "grep -v '^]*$' ... (1 Reply)
Discussion started by: hadsuresh
1 Replies

9. UNIX for Dummies Questions & Answers

deleting files based on file name and modified time

Hi, I have some log files created in the following fashion Ex: file name modified date 1) s.log1 01-jan-08 2) s.log2 02-jan-08 3) s.log3 03-jan-08 4) s.log4 04-jan-08 Now I want to have the latest 2 logs and delete the others. Can you tell me the one liner /... (1 Reply)
Discussion started by: ammu
1 Replies

10. UNIX for Advanced & Expert Users

extract a sub directory form a tar file

anyone know if it is possable to extract a subdirectory in a tar file. IE tarfile contains parent dir -sub dir A -sub dir B I want to extract sub dir B. (2 Replies)
Discussion started by: Optimus_P
2 Replies
Login or Register to Ask a Question