1

I need to tail several files, and most info from them i removing (using grep). Now mine output dirty with file names. How i can remove them?

Short to problem: $ tail -F /log/rest_server*.log | egrep -v ' INFO (<some regext>)'

return:

==> /log/rest_server_dbs0.log <==

==> /log/rest_server_dbs1.log <==
<some useful data1>

==> /log/rest_server_dbs0.log <==

==> /log/rest_server_dbs1.log <==
<some useful data2>

==> /log/rest_server_dbs0.log <==

==> /log/rest_server_dbs1.log <==

==> /log/rest_server_dbs0.log <==

==> /log/rest_server_dbs1.log <==

==> /log/rest_server_dbm0.log <==
<some useful data3>

==> /log/rest_server_dbs1.log <==

==> /log/rest_server_dbs0.log <==

==> /log/rest_server_dbs1.log <==

==> /log/rest_server_dbs0.log <==

==> /log/rest_server_dbs1.log <==

==> /log/rest_server_dbs0.log <==

==> /log/rest_server_dbs1.log <==

==> /log/rest_server_dbm0.log <==
<some useful data4>

==> /log/rest_server_dbs1.log <==

How I can remove this file names and black lines, if there is no data?

to make result

==> /log/rest_server_dbs1.log <==
<some useful data1>
<some useful data2>

==> /log/rest_server_dbm0.log <==
<some useful data3>
<some useful data4>
1
  • Please add some more details. I have no idea what you're asking. Maybe someone with the necessary knowledge could help you, but you are making your question hard to find. Jan 7, 2016 at 21:44

1 Answer 1

0

You can use the following commands instead:

$ tail -F /log/rest_server*.log | sed -e "/^==>/d;/^$/d" | egrep -v ' INFO (<some regext>)'

The sed command removes the lines that start with "==>" and those that are empty;

1
  • with that i will get ` <some useful data1> <some useful data2> <some useful data3> <some useful data4> ` with loosing filenames, when i do get necessary info. I can do the same with only grep, without using sed
    – bm13kk
    Jan 13, 2016 at 18:39

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.