Ls ignoring files from their modification time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ls ignoring files from their modification time
# 8  
Old 05-10-2012
Shell : Ksh (KSH_VERSION='@(#)PD KSH v5.2.14 99/07/13.2')
O.S : Linux (2.6)
Find version : GNU find version 4.2.27
ls version : ls (GNU coreutils) 5.97


Structure : I have 1000 folders (with small variation, for example folder1 - folder1000)
in each folder I have another folder (out)
in "out" I have something like 200 or more files (every folders have the same files).

I want to select "myFile"only if the modification time is lesser than 1month then concatenate all these files..

Find solution
Code:
find / -maxdepth 3 -regex "/folder[0-1000]/out/myfile" -ctime -31 -execdir cat {} \;

ls solution (1month = 31*24*3600=2 678 400 seconds )
Code:
ls -l --time-style=+%s /folder[0-1000]/out/myfile| awk -v current=`date "+%s"` -v threshold="2 678 400" ' { if ( (current-$6) < threshold ) { print $7 } } ' | xargs cat


Last edited by Keyhaku; 05-10-2012 at 12:41 PM..
# 9  
Old 05-10-2012
Quote:
only if the modification time is lesser than 1month
Use -mtime in find (not -ctime).
Your find is using parameters not seen in unix. Perhaps someone with a similar O/S can check them?
The find posted looks like it does a find from root not from a sensible start point (which could take ages to run). What are you actually trying to do and what is the top-level directory structure?

Last edited by vbe; 05-10-2012 at 12:46 PM.. Reason: typo
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Getting files through find command and listing file modification time upto seconds

I have to list the files of particular directory using file filter like find -name abc* something and if multiple file exist I also want time of each file up to seconds. Currently we are getting time up to minutes in AIX is there any way I can get file last modification time up to seconds. (4 Replies)
Discussion started by: Nitesh sahu
4 Replies

2. OS X (Apple)

[OS X] Last modification time from shell in CCYYMMDDhhmm.ss format

This example shows last mtime from epoch $ stat -f %m somefile 752911565 But would like to see it like that: 199311100606.05 (2 Replies)
Discussion started by: Tribe
2 Replies

3. Shell Programming and Scripting

How to change modification time of file?

Explain it with proper e.g (4 Replies)
Discussion started by: sidpatil
4 Replies

4. Shell Programming and Scripting

How to list the files based on the modification time using the find command?

Hi All, I need to list the files based modification time of the files from a directory, I cannot use "ls -t" as there are lot of files, which "ls" command cannot handle. New files will land there daily. So iam looking for an alternative through "find"command. All suggestions are welcomed. ... (6 Replies)
Discussion started by: Kesavan
6 Replies

5. UNIX for Dummies Questions & Answers

Need Modification Time of a file

Hi all, I need the modification time of a file on a particular day say 3 days before. I just don't want the last modification time. I need all the modification times on a particualar day. Is there anyway to do it? Kindly help. Could anyone tell me where the modification time is stored?... (1 Reply)
Discussion started by: vidhyab
1 Replies

6. Shell Programming and Scripting

Find and symbolic link modification time

Hi, I have a directory made up of many symbolic links to folders multiple file systems. I want to return folders modified within the last 50 days, but find is using the link time rather than the target time. find . -type d -mtime -50 Is there a way to either: a) Make a symbolic link... (1 Reply)
Discussion started by: earls
1 Replies

7. Shell Programming and Scripting

File modification time comparison

Hi All, I have two files (given below) each exists under different paths. I want to compare the modification time stamp of file1.txt is lessthan the modification time of file2.txt. month1=`ls -l file1.txt | awk '{ print $6}'` date1=`ls -file1.txt | awk '{ print $7}'` time1=`ls... (1 Reply)
Discussion started by: Arunprasad
1 Replies

8. Shell Programming and Scripting

time modification in script

Hi All.. I have a file with a number of non-unique entries as below: 1243 01:42:29,567 --> 01:42:32,108 blah blah .... blah blah .. 1244 01:42:32,709 --> 01:42:34,921 blah blah .... 1245 01:42:35,214 --> 01:42:36,533 blah blah .... blah blah .. blah blah .... blah blah .. (4 Replies)
Discussion started by: UniRock
4 Replies

9. Shell Programming and Scripting

Archive Files over certain modification time

Environment is cygwin on Windows Server 2003 as I could not think how I would achieve this using Windows tools. What I want ot achieve is the following. I have a Directory D:\Data which contains further subfolders and files. I need to move "files" older than 6 months modification time to... (4 Replies)
Discussion started by: jelloir
4 Replies

10. UNIX for Dummies Questions & Answers

File modification time

Does anyone know how to display the time with seconds of when a file was last modified. I can get hour & minutes but would also like seconds. --Running AIX (1 Reply)
Discussion started by: edog
1 Replies
Login or Register to Ask a Question