0

I have created the following alias in my .bashrc file:

alias find='find . -type f -name'

This obviates the need to type . -type f -name every time I do a file search. However, I still have to enclose search strings with '*...*'. How could I include these in the alias, so that instead of having to type:

find '*string*'

I could just type,

find string
Edman
  • 472
  • 2
  • 9
  • 4
    See [How to pass parameters to an alias?](https://unix.stackexchange.com/questions/3773/how-to-pass-parameters-to-an-alias), [In Bash, when to alias, when to script, and when to write a function?](https://unix.stackexchange.com/questions/30925/in-bash-when-to-alias-when-to-script-and-when-to-write-a-function) – steeldriver Jul 27 '21 at 17:12

1 Answers1

2

It is not easy with an alias but you can just define a shell function instead.

find() { /usr/bin/find . -type f -name "*$1*"; }