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.

Was it helpful?

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"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top