Frage

I find myself running this command all the time

grep -r "somestring" /workplace/scripts /workplace/server

I would like to replace it with a simple custom command

s "somestring"

which will do the same thing.

how do I do this? I'm new to linux.

War es hilfreich?

Lösung

Your example suggests that the variable is the search string. You could define a function:

s() {
  grep -r -- "$1" /workplace/scripts /workplace/server
}

and invoke it by saying:

s "somestring"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top