LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 02-16-2017, 12:17 PM   #1
bodisha
Member
 
Registered: Oct 2016
Posts: 36

Rep: Reputation: Disabled
weird 'find' results


Hello and thanks in advance for any help anyone can offer me

The fast & dirty question is... Why does 'find' return the bash shell scripts when they don't met my criteria?

The longer question is I'm trying to learn the 'find' command and thought I was understanding it... Apparently I was wrong. I was doing compound searches and I started getting weird results with the -size test. I was trying to do a search on a 1G file owned by the user database. I was expecting to get a single file back, but for some reason the 'find' returns not only the 1G file but the scripting files owned by the database user. I've been messing with this for a while trying to understand it. I can filter it out by using a '-not -name ".*" but that's not the point. I want to understand why it's including the start up scripts & what I'm doing wrong. Here's the command and the results... If someone could tell me what I'm doing wrong I would greatly appreciate it!!!

find /home -type f -user database -size 1G -ls
13774125 4 -rw-r--r-- 1 database database 18 Nov 20 2015 /home/database/.bash_logout
13774135 4 -rw-r--r-- 1 database database 193 Nov 20 2015 /home/database/.bash_profile
13774136 4 -rw-r--r-- 1 database database 231 Nov 20 2015 /home/database/.bashrc
13774141 1048576 -rw-r--r-- 1 database root 1073741824 Feb 16 11:10 /home/database/large1.log

Last edited by bodisha; 02-16-2017 at 12:44 PM.
 
Old 02-16-2017, 12:39 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Whatever units you specify for size, find will round sizes up to that unit, so "-size 1G" will find all files larger than 0G and no larger than 1G. Think of is as, "If space were allocated in blocks of this size, how many blocks would this file require."
 
Old 02-16-2017, 03:25 PM   #3
jerryq
LQ Newbie
 
Registered: Mar 2007
Posts: 4

Rep: Reputation: 0
From the man page, numeric arguments can be specified as :
+n for > n
-n for < n
n for exactly n
and for size n says "using n units of space", so you can use -size +1G to match files that use > 1G of space.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MDADM gives weird results andrew.durnez Linux - Software 1 04-16-2012 02:51 PM
MDADM gives weird results andrew.durnez Linux - Newbie 5 04-16-2012 08:04 AM
Weird results from CHKrootkit jim.thornton Linux - Security 3 01-30-2008 07:25 AM
Bash - weird results from if The_JinJ Programming 3 02-13-2005 02:11 PM
Weird results from who and finger cauchy Linux - General 0 10-14-2001 10:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 02:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration