BSalunke
BSalunke

Reputation: 11727

how to search for pattern in file and display the line on terminal?

i have filw with containtent like following:

pid 4565 Process: /my/name/is/4678 +34787[d]sfh888dwe4rtertfsj@##$
pid 33453 Process: /my/name/is/4678 +34787[d]sfh888dfsj@##werwer$
pid 3453345 Process: /my/name/is/4678 +3478[7]dsfhew46534wy6888dfsj@##$
pid 12335 Process: /my/name/is/4678 +3478se[r]tet57dsfh888dfsj@##$

i need line contaning "+34787[d]sfh888dfsj@##werwer$" this pattern and need to get whole that line on terminal or can ne redirected to another file. Any suggestion? Thanks in advance.

Upvotes: 1

Views: 443

Answers (2)

Michał Šrajer
Michał Šrajer

Reputation: 31182

Use grep with fixed strings mode (aka fgrep):

grep -F '+34787[d]sfh888dfsj@##werwer$' /path/to/my/file

Run man grep to learn more.

If you need to redirect it to some output file instead of standards output:

grep -F '+34787[d]sfh888dfsj@##werwer$' /path/to/my/file > /path/to/my/output

Run man sh or man bash and read about Redirections.

Upvotes: 1

Kent
Kent

Reputation: 195059

grep/awk/sed... many tools can do that. grep example:

 kent$  echo "pid 4565 Process: /my/name/is/4678 +34787[d]sfh888dwe4rtertfsj@##$
    pid 33453 Process: /my/name/is/4678 +34787[d]sfh888dfsj@##werwer$
    pid 3453345 Process: /my/name/is/4678 +3478[7]dsfhew46534wy6888dfsj@##$
    pid 12335 Process: /my/name/is/4678 +3478se[r]tet57dsfh888dfsj@##$"|grep '\+34787\[d\]sfh888dfsj@##werwer\$'

    pid 33453 Process: /my/name/is/4678 +34787[d]sfh888dfsj@##werwer$

Upvotes: 0

Related Questions