Y
Y
YaroslavKleyno2018-03-05 21:10:46
linux
YaroslavKleyno, 2018-03-05 21:10:46

Need help with awk - write a regular expression to parse a file?

Good afternoon! It's a simple task. There is a telegram console client - you need to parse its logs for the web muzzle through awk.
Here are the logs he keeps:
05 Mar 18 19:33 EET 23670 382477216 Kleino Yaroslav to 224615209 Hermelin Nerz: something is happening 05 Mar 18
19:33 EET 23671 382477216 Kleino Yaroslav to 224615209 Hermelin Nerz: write to me write to me))
33 EET 23672 224615209 Hermelin Nerz to 382477216 Kleino Yaroslav: OK
05 Mar 18 19:33 EET 23673 224615209 Hermelin Nerz to 382477216 Kleino Yaroslav: What is
05 Mar 18 19:33 EET 23674 382477216 Kleinno Yaroslav to 224615209 Hermelin Nerz: Thank you
05 Mar 18 19:33 EET 23675 382477216 Kleino Yaroslav to 224615209 Hermelin Nerz: I'm testing
05 Mar 18 19:33 EET 23676 224615209 Hermelin Nerz to 382477216 Kleino Yaroslav: Still out?
From here we need
19:33 Hermelin Nerz: Still not done?
I parse like this:
cat /home/yaroslav/screen.log | grep Hermelin | awk '{print $4, $8, $14 $15 $16 $17 $18}'
but the result is
19:33 Hermelin Is everything out yet?
how to add spaces to a message?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
3
3vi1_0n3, 2018-03-06
@YaroslavKleyno

Maybe sed after all?
The output will be:

19:33 Hermelin Nerz: О.о
19:33 Hermelin Nerz: Что такое
19:33 Hermelin Nerz: Всё ещё не вышло?

for all:
At the exit:
19:33 Клейно Ярослав: чтото происходит
19:33 Клейно Ярослав: пиши мне пиши))
19:33 Hermelin Nerz: О.о
19:33 Hermelin Nerz: Что такое
19:33 Клейно Ярослав: спасибо
19:33 Клейно Ярослав: я тестирую
19:33 Hermelin Nerz: Всё ещё не вышло?

V
Vit Vas, 2018-03-25
@GorodokVVV

Since awk inserts spaces between fields nicely with " " (space between quotes), why would sed also include it?
The line will look like this:
awk '{print $4, $8, $14 " " $15 " " $16 " " $17 " " $18}'
Read this article .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question