How to define a function in bash and select one of the files with the same name for editing after finding multiple files with the same name?

such as the title.

the function I implement now is to find the first file even if I open it with vim for editing:

vfin() {vim $(find / -iname "$1")}

but most of the time, you need to select one of the multiple files with the same name to edit. How do you do this with the bash function?

Sep.04,2021

use the pipe to fetch the first line

vim $(find / -iname "$1" | head -n 1)
Menu