I need to simplify this command:
grep 'SEARCHTERM' server.log | grep -v 'PHHIABFFH' | grep -v 'Stats'
It should find all lines, including SEARCHTERM, but exclude if one of the lines SEARCHTERMincludes PHHIABFFHor Stats.
SEARCHTERM
PHHIABFFH
Stats
This will work:
grep 'SEARCHTERM' server.log | grep -Ev 'PHHIABFFH|Stats'
Why do you want to "simplify" this channel? Un * x command line tools are designed to be chained this way.
Edit
Some answers suggest using the functions of certain versions of grep. I like it, but it is very possible that such specific functions are not available in the grep version used by the OP.
, , OP, , , .
Un * x.
. , Unix Shell 4GL [Schaffer-Wolf] , , .
http://www.catb.org/~esr/writings/taoup/html/ch07s02.html#plumbing
...
awk '$0 !~ /PHHIABFFH|Stats/ && /SEARCHTERM/' server.log
while read -r line do case "$line" in *"Stats"*|*"PHHIABFFH"*) continue;; *"SEARCHTERM"* ) echo "$line";; esac done < "file"
:
grep 'SEARCHTERM' server.log | grep -v -e 'PHHIABFFH' -e 'Stats'
Source: https://habr.com/ru/post/1723976/More articles:PHP: отображать записи из базы данных группами по пять? - sqlC # - event design considerations - c #circular set of elements in jquery - jqueryUsing a hash function to create an unforgettable personality for objects - pythonWhy do Postgres refuse to start the service? - windowsHow to export a single table from phpmyadmin to a comma delimited text file? - mysqlHow to use the interface as a map key - javaIs 100 billion records a day at Oracle a problem? - oracleHow to get the arch string that distutils uses to build? - pythonExport custom Sharepoint list options - sharepointAll Articles