Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 10-02-2015, 10:11 AM   #1
Registered: Mar 2010
Distribution: slackware64 current
Posts: 104

Rep: Reputation: 4
find with -print or -exec does not print found file

I created a normal user in linux, then created a emptyfile in /tmp directory. delted user
and using find command, locate it. then I found this.

root@garlicbread:[/]# find tmp -nouser -o -nogroup
root@garlicbread:[/]# find tmp -nouser -o -nogroup -print
root@garlicbread:[/]# find tmp -nouser -o -nogroup -exec ls -l '{}' \;
as you can see if I use -print or -exec option, find does not locate the target file

root@garlicbread:[/]# find tmp -nouser -o -nogroup | xargs ls -l
-rw------- 1 1001 users 0 10월  2 10:44 tmp/ownedbytest
I can use xargs to list as long option, but I noticed that if find does not find any file it execute with empty arguments thus listing current directory.

root@garlicbread:[/]# find tmp -nogroup | xargs ls -l
total 97
drwxr-xr-x   2 root root  4096 Sep 28 06:54 bin
drwxr-xr-x   4 root root  1024 Sep 28 06:28 boot
drwxr-xr-x  17 root root  5940 Oct  1 07:51 dev
drwxr-xr-x 101 root root 12288 Oct  2 10:45 etc
drwxr-xr-x   5 root root  4096 Oct  2 10:45 home
drwxr-xr-x   7 root root  4096 Aug 20 03:02 lib
drwxr-xr-x   2 root root 12288 Sep 28 08:22 lib64
Does anyone know why find does not execute as expected?

I'm using slackware64 14.1
Old 10-02-2015, 10:31 AM   #2
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
find tmp -nouser -o -nogroup -print
From man page:

       expr1 expr2
              Two expressions in a row are taken to be joined with an implied "and"; expr2 is not
              evaluated if expr1 is false.
The file has a valid group. -nogroup is FALSE so -print is never evaluated. Try grouping your conditions.
find tmp \( -nouser -o -nogroup \) -print
Old 10-02-2015, 10:38 AM   #3
Registered: Mar 2010
Distribution: slackware64 current
Posts: 104

Original Poster
Rep: Reputation: 4
I see. the problem was that -nogroup and -print is joined with -and

Thank you for your answer. I appreciate it


find command

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 05:30 PM
[SOLVED] find /common -name lost+found -prune -or -name fileTofind -print kaz2100 Linux - General 2 11-05-2012 04:36 AM
'find' gives different results when using -mtime with -print vs -exec BrianK Linux - General 1 12-08-2008 10:32 AM
Print-to-file print driver to print PDF Bill Fox Linux - General 3 05-02-2006 04:15 PM
Setting up a print to file print driver Bill Fox Linux - General 0 02-26-2005 01:22 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:28 AM.

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