Search code examples
unixpermissionsfindredhat

Unix RedHat - Can't exclude "Permission denied" message on "find" command


I'm working on RedHat unix server and I need to run a 'find' command to search some text files but ever 'find' return "Permission denied" for some directory.

I searched on other similar posts here on stack overflow but no one of the given answers has resolved my issue.

This is the command I run:

    find . -name "*file_name*20200310*"

An these are the option I tried without success:

    find . -name "*file_name*20200310*" -type f

    find . -name "*file_name*20200310*" 2>/dev/null

    find . -name "*file_name*20200310*" | grep -v "Permission denied"

    find . -name "*file_name*20200310*" -nowarn   # really, this option '-nowarn' is about

warning

I red the find manual (unix 'man') but didn't find a solution.

Please, anyone can help me ? Thanks in advance.

Ale.


Solution

  • … these are the option I tried without success:

    …
        find . -name "*file_name*20200310*" | grep -v "Permission denied"
    …
    

    I'm on /usr/bin/csh

    To make this work with csh, we have to use the pipe operator |& which redirects also stderr:

    find . -name "*file_name*20200310*" |& grep -v "Permission denied"