Skip to main content
Post Closed as "Duplicate" by jesse_b, suspectus, Christopher, CommunityBot
Add mentioning of sudo to title (and tags)
Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

alias the find function and use it with sudo

Source Link

alias the find function

I'm having trouble creating an alias so I can run find in "silent mode" (without all the Permission denied messages). my bash skills are pretty bad so I'm not sure how to fix this

here's my alias in ~/.bashrc:

alias find='function _find(){find / -name "$1" 2>&1 | grep -v "Permission denied"}'

so if I run source ~/.bashrc and then sudo find "Exercism", I get an output of find: ‘Exercism’: No such file or directory

but running find / -name "Exercism" 2>&1 | grep -v "Permission denied" yields the correct result.

I'm not sure I'm passing the argument right, or at all, into the aliased find function.