What is wrong with 'find . -maxdepth 1 -ctime -7 -type f'?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What is wrong with 'find . -maxdepth 1 -ctime -7 -type f'?
# 1  
Old 03-13-2017
What is wrong with 'find . -maxdepth 1 -ctime -7 -type f'?

Have you tried running the command below? On the same RHEl 6.8 or 6.6. It will give you different output.

Code:
find . -maxdepth 1 -ctime -7 -type f

Code:
rpm -qa|grep find
findutils-4.4.2-9.el6.x86_64

Code:
[root@soctxtwave06:~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.8 (Santiago)
[root@soctxtwave06:~]#

# 2  
Old 03-13-2017
Um, okay. Please help us.

I assume the output differs on the very same directory tree. Could please post what you found as the difference?
# 3  
Old 03-13-2017
find manpage: FWIW, and in case this is the result of not knowing about rounding, you may need to read this section. We get this question often.

(yes, I know it is about atime)
Code:
    -atime n
              File  was  last  accessed n*24 hours ago.  When find figures out
              how many 24-hour periods ago the file  was  last  accessed,  any
              fractional part is ignored, so to match -atime +1, a file has to
              have been accessed at least two days ago.

Next read the ctime piece, which refers back to atime

Code:
       -ctime n
              File's status was last changed n*24 hours ago.  See the comments
              for -atime to understand how rounding affects the interpretation
              of file status change times.

This User Gave Thanks to jim mcnamara For This Post:
# 4  
Old 03-13-2017
THIS IS CORRECT,
Code:
-rw-r-----.  1 root domain users         81 Mar  7 15:51 aa
drwxrwxr-x. 13 root domain users       4096 Mar  8 14:25 development
drwxr-x---.  2 root domain users       4096 Mar 13 16:19 630
[root@server1:~]$  find .  -maxdepth 1 -type f  -ctime -7
./.bash_history
./aa
./.viminfo
[root@server1:~]$


Same release and find version
Code:
[root@server2 ~]# ls -lrt | tail -4
drwxr-x---. 2 root    root         4096 Mar  7 15:53 bin/
-rw-r-----. 1 root    root            0 Mar 13 17:52 asdas
-rw-r-----. 1 root    root            0 Mar 13 17:54 aa
-rw-r-----. 1 root    root            0 Mar 13 18:04 asdf
[root@server2 ~]#


root@server2 ~]#  find .  -maxdepth 1 -type f  -ctime -7
./.tcshrc
./get_index_data.pl.20150602
./install_trace.34856
./.bashrc.20161130
./.viminfo
./bondNIC.sh
./install.log.syslog
./tao-cosconcurrency.20160720
./ks-post.log.1
./asdf
./get_index_data.pl_ORIG
./getAttachmentNames
./twave05.key




# ll install.log
-rw-r--r--. 1 root root 28080 Feb 17  2015 install.log
[root@server2 ~]#

---------- Post updated at 02:42 AM ---------- Previous update was at 02:33 AM ----------

what funny is...my command works on my other rhel servers. the same command..atime is totally different as well as mtime..believe me..i ran all the tests.
# 5  
Old 03-13-2017
Perhaps the atime and mtime really are different on that particular server, at no fault of find's.
# 6  
Old 03-17-2017
Ok thank you..maybe we close this ticket
# 7  
Old 03-17-2017
Maybe you thought there is a shared filesystem.
df . tells you the filesystem where the current directory is, and ls -lid tells the current directory's inode number.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find -ctime -1 cannot find files without extention

The problem is this one. I tar and gzip files on remote server find . -ctime -1 | tar -cvf transfer_dmz_start_daily.tar *${Today}*.*; Command find . -ctime -1 Doesn't find files without extension .csv .txt I have to collect all files for current day, when the program... (1 Reply)
Discussion started by: digioleg54
1 Replies

2. Shell Programming and Scripting

find -ctime -1 cannot find files without extention

The problem is this one. I tar and gzip files on remote server Code: find . -ctime -1 | tar -cvf transfer_dmz_start_daily.tar *${Today}*.*; Command Code: find . -ctime -1 Doesn't find files without extension Code: .csv .txt I have to collect all files for current... (1 Reply)
Discussion started by: digioleg54
1 Replies

3. Answers to Frequently Asked Questions

find "/path" -type f -ctime +30

When I use the command find "/abc/xyz" -type f -ctime +30 getting the error as find:"/abc/xyz /lost+found: Permission Denied" I tired find "/abc/xyz" -type d \( ! lost+found \) -type f -ctime +30 The error is find: paths must precede expression Usage: find Tried find "/abc/xyz"... (1 Reply)
Discussion started by: anithab
1 Replies

4. Shell Programming and Scripting

Maxdepth option of find command not working

Can you please figure out what is the issue here $ find . -maxdepth 1 -type f -size 0 -print find: bad option -maxdepth please find the OS details $ uname -a HP-UX g5u1216 B.11.31 U ia64 2614088426 unlimited-user license Use code tags, thanks. (6 Replies)
Discussion started by: TomG
6 Replies

5. Shell Programming and Scripting

find -ctime

startdate="2012_07_04-16:14:4" path1="/home/drdos/sample" days=0 find $path1 -name "*$startdate*" > teste.txt while do find $path1 -name "*.zip" ctime $days > teste.txt days=`expr $days + 1` done echo " Files that are near the string u search are on teste.txt"Hi to... (2 Replies)
Discussion started by: drd0spt
2 Replies

6. Shell Programming and Scripting

find -ctime

I know that find -ctime +1 will find ALL files that have been modified that are greater than 1 day old and -ctime 1 will find files that are ONLY 1 day old -ctime -1 mean files that are less than a day old? Can find actually use this granularity? (5 Replies)
Discussion started by: BeefStu
5 Replies

7. UNIX for Dummies Questions & Answers

"-maxdepth 1" argument for Solaris find. Other way to restrict find in only one directory?

Hi I wish to find only files in dir /srv/container/content/imz06/. It means exclude subfolder /srv/container/content/imz06/archive/ > uname -a SunOS testbox6 5.10 Generic_139555-08 sun4v sparc SUNW,Sun-Blade-T6320Its Solaris default "find" > find /srv/container/content/imz06/* -name... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

8. UNIX for Dummies Questions & Answers

Solaris find without maxdepth

Hi, I am using Solaris 5.8 I searched online, the find command has an option called maxdepth which can be used to limit the number of directories find will look into. find . -maxdepth 2 -type f When I run the above command in solaris, I get an error find: bad option -maxdepth find:... (2 Replies)
Discussion started by: Leion
2 Replies

9. Shell Programming and Scripting

how to find ot ctime , mtime ,atime

Can any one tell me how to find out ctime , mtime ,atime for a file/directory on unix. Cheers, Nilesh (5 Replies)
Discussion started by: nilesrex
5 Replies

10. UNIX for Dummies Questions & Answers

ctime & find

I am trying to figure out the syntax to use find to remove files older than 30 minutes. I know that this will work for files 1 day old, but cannot seem to trim the time down to 30 minutes. find /path/to/file -ctime +1 -exec rm -f {} \; (1 Reply)
Discussion started by: 98_1LE
1 Replies
Login or Register to Ask a Question