Results 1 to 2 of 2
Hello there,
Anyone knows how to manage the find command to return true or false if a file was found/or not? I tried to man find but didn't found anything.
...
- 05-18-2011 #1Just Joined!
- Join Date
- May 2011
- Posts
- 5
find command return true if a file was found
Hello there,
Anyone knows how to manage the find command to return true or false if a file was found/or not? I tried to man find but didn't found anything.
Regards,
- 05-18-2011 #2
The exit status of a program is written into it and can't be changed by a user. The behaviour of find in this respect is described in the man page:
"find exits with status 0 if all files are processed successfully, greater than 0 if errors occur. "
If you want a command that returns 1 when a file is not found, try piping a listing of the directory into grep. For a directory tree, use find -name "*" to list all subdirectories and their contents and pipe the result into grep."I'm just a little old lady; don't try to dazzle me with jargon!"


Reply With Quote