Sobes.tech
Junior — Middle

In what cases and how do you use the grep command in your projects?

sobes.tech AI

Answer from AI

I use the grep command for quickly searching for specific lines in files or the output of other commands. This is convenient for log analysis, searching for specific functions or variables in code, as well as filtering results.

Examples of usage:

  • Search for all errors in a log:
grep "ERROR" application.log
  • Search for a function in source files:
grep -rn "functionName" ./src
  • Filter processes by name:
ps aux | grep node

I also use options -i for case-insensitive search, -v to exclude lines, and -r for recursive search through directories.