Z
Z
Zelyoniy2019-02-05 20:53:51
linux
Zelyoniy, 2019-02-05 20:53:51

How to output strings without brackets?

There is a log file containing lines like this:
February 4 17:00:00 Motor depot [Platform, Chassis]
February 5 18:00:00 Motor depot [Platform, Chassis] February
4 19:00:00 Motor depot Direction: Workshop
How output only the first and second lines without the third in the form:
February 4 Chassis, Platform
?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2019-02-05
@ky0

grep '[\|]' logfile | awk '{print $1, $2, какие там ещё вам нужны колонки}' | sed s/меняем_скобки/на_пустоту/g

S
Soslan Khloev, 2019-02-05
@hloe0xff

Well, if the key factor is the presence or absence of square brackets, then grep is enough .grep -E '([|])' file.log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question