shell - shell - Removing output of 'find' command failures - answerstu - answerstu.com answerstu

2 Answers

  1. Mark- Reply

    2019-11-13

    I would recommend the following command since you are looking for programs:

    find "$path" -type f -name programName 2>/dev/null
    

    where 2>/dev/null mute your stderr (for more info: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html).

    to force find to return only files since you might have a folder called programName, with your current command it will be picked up by the find command.

    Also, what you could add is the -executable option if not available use: -perm /u+x to add the constraint that you are looking for files and those files should be executable.

    find "$path" -type f -name programName -executable 2>/dev/null
    
  2. Marks- Reply

    2019-11-13

    Try:

    find "$path" -name programName -type f 2>/dev/null
    

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>