find command not giving file names accord. to timestamps


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers find command not giving file names accord. to timestamps
# 1  
Lightbulb find command not giving file names accord. to timestamps

Currently iam working on solaris environment,
Iam using find command to get list of all files between any two given dates. But the find command is not listing files accord. to timestamp. I tried using -exec option as -exec ls -ltr {} \;
Still the files are not listed according to timestamp..
Can anyone help me on this..

find . -type f -name '*xyz*' -newer start.file ! -newer end.file
-exec ls -ltr {} \;
# 2  
Try using...

find . -type f -name '*xyz*' -newer start.file ! -newer end.file -exec ls -ltr {} \+

Or...

find . -type f -name '*xyz*' -newer start.file ! -newer end.file -print | xargs ls -ltr

However, neither method is guaranteed to work for large numbers of matched files.
# 3  
I have 200 or more files , I already tried -exec ls -ltr {} \; option, but it didn't work...
# 4  
The -exec ls -ltr {} \; option invokes the ls command for each matched file. Try one of the two suggestions above.
# 5  
Question could work!?

try !
find . -type f - ctime or (mtime) depending on what you're looking for ..
find . -type f - ctime +20 -name "*" -exec ls -alt {} \;
find . -type f -mtime -30 -name "*" -exec ls -alt {} \;
i believe there is also an atime.. (man find should tell which choice to make)..
moxxx68
Smilie
# 6  
find . -type f -name '*xyz*' -newer start.file ! -newer end.file -exec ls -ltr {} \+
The above cmd is not giving files accord. to timestamp , so doesn't give required o/p

find . -type f -name '*xyz*' -newer start.file ! -newer end.file -print | xargs ls -ltr

The above cmd is giving files accord. to timestamp , this is working as required...

Also the below cmd is working.......
ls -ltr `find . -type f -name '*xyz*' -newer start.file ! -newer end.file -print `

Thanks for your inputs...
# 7  
I want to get all the files between start.file and end.file in the current directory only (not files in the sub directories).

find . -type f -name '*xyz*' -newer start.file ! -newer end.file -print

With the above command , Iam getting files in subdirectories of the current directory also... How to avoid this.. Can someone help us...
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #992
Difficulty: Medium
OpenSolaris and its derivatives are the only SVR4 descendants that are not open-source software.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find command giving bad status error

In a fastload teradata utility I am trying to delete the files which are older than 30days using the find and rm command as following. find . -name 'xxx_*' -mtime +30 -exec rm -f {} \; I expect it to delete all the files older than 30 days but sometimes it gives an error : find: bad status--... (3 Replies)
Discussion started by: stelkar
3 Replies

2. Shell Programming and Scripting

Find matching file in bash with variable file names but consisent prefixs

As part of a bash the below line strips off a numerical prefix from directory 1 to search for in directory 2. for file in /home/cmccabe/Desktop/comparison/missing/*.txt do file1=${file##*/} # Strip off directory getprefix=${file1%%_*.txt} ... (5 Replies)
Discussion started by: cmccabe
5 Replies

3. Shell Programming and Scripting

Find file between timestamps Query

On my linux box, I have a file say dump.txt. I then need to move to another seperte folder and need to find only one file with extension *.tar that has the closest timestamp after / next to the timestamp of the dump.txt. (2 Replies)
Discussion started by: mohtashims
2 Replies

4. UNIX for Dummies Questions & Answers

find command: names matching the expression

Hello all, I need to print directories using find command. The directories names contain date in the format YYYYMMDD or the name of directory is only the date format. I want print directories, which doesn't start with this date. E.g I have dirs like foo20120101 foo20120101foo 20120101foo... (1 Reply)
Discussion started by: satin1321
1 Replies

5. Shell Programming and Scripting

find command giving incomplete sentence warning

Hi , I am adding a line in my shell scripts to delete all the old directory with the below command. On running this command it is coming out with the message find: incomplete statement find /ersdg3/ERS/ERS_INPUT_LOGS/RIO/rio_archive -type d -mtime +47 -exec rm -rf {} What is wrong or... (3 Replies)
Discussion started by: guddu_12
3 Replies

6. Shell Programming and Scripting

find specific file names and execute a command depending on file's name

Hi, As a newbie, I'm desperate ro make my shell script work. I'd like a script which checks all the files in a directory, check the file name, if the file name ends with "extracted", store it in a variable, if it has a suffix of ".roi" stores in another variable. I'm going to use these two... (3 Replies)
Discussion started by: armando110
3 Replies

7. Shell Programming and Scripting

How to find pattern in file names?

I have some files, those are abbreviated (ed,ea, and bi) company_ed_20100719.txt company_ea_20100719.txt company_bi_20100719.txt I would like to rename these files by replacing ed with EmployeeDetails ea with EmployeeAddress bi with BankInfomration as company_... (3 Replies)
Discussion started by: LinuxLearner
3 Replies

8. UNIX for Advanced & Expert Users

Find File names with sustitution

Hi All, Iam trying to find two kinds of files while ignoring rest of the files in a directory The files are like below Files to be found -------------------- perp45560 oerp4556 Files to be ignored ---------------------- oerp4556123450 oerp4556123470 I was trying the following... (4 Replies)
Discussion started by: baanprog
4 Replies

9. UNIX for Advanced & Expert Users

mv command and file-timestamps

Hi all, I need help to find out if it is possible (if so, how? :D ) to move a hard link to a given file without making the main file i-node modification time change. That is: I have a file myFile.txt , and I have a link myLink.dat to that file (obtained by: ln myFile.txt myLink.dat).... (1 Reply)
Discussion started by: gian1975
1 Replies

10. Shell Programming and Scripting

Find command to get the timestamps

I want to have the timestamps of the files containing a specific string in them. I have tried using different combinations of find command and grep and ls but not giving the desired output. find $HOME/bin/shells -name "*" -print -exec ls -Flt {} -exec grep -i "abc" '{}' \; Please help. (8 Replies)
Discussion started by: nguda
8 Replies

Featured Tech Videos