0

My goal is to write a command to locate a file called MABLE on my server. Then I need to craft this command to report no permission errors, but print out every other error.

Currently, I'm using

find / -name MABLE 

After that, I'm putting in

ls -d mable

This is not working. Any better way write the command?

zx485
  • 2,249
  • 11
  • 24
  • 34
jjc
  • 9
  • 2
  • 2
    I'm confused; *MABLE* and *mable* are very different names, and a command searching for files is case-sensitive (so case matters!) unless you specifically tell it to ignore case (`-iname` for example). Why are you using MABLE then mable - they'll be two different files. – guiverc Sep 01 '21 at 00:47
  • 1
    if you intend to search for a file on the entire system, then `locate` is probably better siuted. –  Sep 01 '21 at 06:28
  • 1
    Does this answer your question? [Missing Downloads folder](https://askubuntu.com/questions/1348082/missing-downloads-folder) – CrazyTux Sep 01 '21 at 14:57

1 Answers1

1

You can use "process substitution" to pass the results of the find command to grep, in order to filter out the messages including : Permission denied as in:

find / -name MABLE 2> >(grep -v ': Permission denied')

2> captures the error output and redirects that to the grep command, to which that output appears as a file (an "unnamed pipe").

vanadium
  • 82,909
  • 6
  • 116
  • 186