Question

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.

Était-ce utile?

La solution

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"
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top