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开发者_C百科/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.
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.
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$
精彩评论