0

In my output file I have the below lines included multiple times along with the required output.

WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.
WARN: Please see http://www.slf4j.org/codes.html#release for an explanation.

Here is how my output looks like.

####################################################################
Raw Error: count of the error records with latest trans session in "audit_preatlas_wb4370_raw_error_05012016073248" table
====================================================================
count   trans_session

WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.
WARN: Please see http://www.slf4j.org/codes.html#release for an explanation.
********************************************************************
Raw Audit: Total records available in "audit_preatlas_wb4370_raw_audit_05012016073248" table
====================================================================
count   trans_session

Raw Audit: Distinct records of "audit_preatlas_wb4370_raw_audit_05012016073248" table
====================================================================
count   trans_session

WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.
WARN: Please see http://www.slf4j.org/codes.html#release for an explanation.
Raw Audit : count of duns with error "gbwr_raw_audit_mandatory_field" code in "audit_preatlas_wb4370_raw_audit_05012016073248" table
====================================================================
count   trans_session   error_code

WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.
WARN: Please see http://www.slf4j.org/codes.html#release for an explanation.
Raw Audit : count of duns with error "gbwr_raw_audit_numeric_field" code in "audit_preatlas_wb4370_raw_audit_05012016073248" table
====================================================================
count   trans_session   error_code

WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.
WARN: Please see http://www.slf4j.org/codes.html#release for an explanation.

How can I remove the WARN lines alone?

  • grep -v WARN: filename – Valentin Bajrami May 19 '16 at 14:04
  • Do you want to view the file without those lines (grep -v "^WARN"), or update the file so those lines no longer exist (sed .....)? – EightBitTony May 19 '16 at 14:05
  • sed -i -e '/^WARN/d' filename maybe ?? I mean if you want them gone from the file not just preventing them from displaying, which is what grep is used for. Of course you can redirect th grep output to a file as a second alternative. – MelBurslan May 19 '16 at 14:05
  • I have a command that is generating the output. How to use grep in that case? command > output.txt – Alex Raj Kaliamoorthy May 19 '16 at 14:08
  • command | grep -v "^WARN" > output.txt – stevieb May 19 '16 at 14:10
2

So there are a few ways. To summarize the comments above you can do one of the following:

awk:

awk '!/^WARN/' filename

sed:

sed '/^WARN/d' filename

grep:

grep -v '^WARN' filename

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.