Welcome to the Linux Foundation Forum!

communication of grep

how grep command communicate with sheel and terminal?

next question is:

how grep command find the particular word which is being searched?

Comments

  • kryptikos
    kryptikos Posts: 61
    Not sure what you are asking here. Are you just wanting to understand the command grep and how to use it? The best places to start are always with the man pages. From your terminal type :

    man grep

    That will bring up the system information about grep and the command structure in how to use it.

    For instance...if you wanted to find all process that were java you would run:

    ps aux | grep java

    If you wanted to find out the information about a particular user account you would enter:

    grep <username> /etc/passwd
  • If you are wondering what it can use for input, you can redirect stdin to it, (Which you are basically doing, when you use the | in your command). Or you can specifiy a file to read. It outputs to stdout. If you need to output to a file, you can always redirect the output with > or >> if nessecary.

    So grep <username> /etc/passwd >> results.txt - would search the passwd file for all instances of <username> and would create the txt file with the results.

    Is this what you are looking for?

Categories

Upcoming Training