Explore BrainMass

Explore BrainMass


    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Please explain GREP

    ? What the command does, how it could be used
    ? Important options or switches
    ? 3 Examples I can use in a UNIX machine

    © BrainMass Inc. brainmass.com March 4, 2021, 6:21 pm ad1c9bdddf

    Solution Preview

    see the attachment

    Finds text within a file.
    grep is not only one of the most useful commands, but also, mastery of grep opens the gates to mastery of other tools such as awk , sed and perl .
    grep [-b] [-c] [-h] [-i] [-l] [-n] [-s] [-v] [-w] text filenames
    -b Precede each line by the block number on which it was found. This can be useful in locating block
    -c Print only a count of the lines that contain the pattern.
    -h Prevents the name of the file containing the matching line from being appended to that line. Used when searching multiple files.
    -i Ignores case.
    -l Displays the files that have the text not the text within the file.
    -n Precede each line by its line number in the file (first line is 1).
    -s Suppress error messages about nonexistent or unreadable files.
    -v Specifies you are looking for files that don't contain the text.
    -w Search for the expression as a word as if surrounded by < and >.
    text The text that you are searching / not searching for. See also below patterns.
    filenames the name of the file that you are searching in.
    Kinds of Patterns for searching.
    . Matches single character.
    * Wild character Example C* if found would pull up CC or CAT...
    {} Matches any character contained within the bracket.
    ^ Represents the beginning of the line, so if you did ^T it would search for any sentence starting with a T.
    $ Represents the end of the line, so if you did $. then it would pull up any lines that ended with .
    Means to take the next ...

    Solution Summary

    UNIX COMMANDS are assessed. The command which could not be used is determined. Important options or switches are determined.