H
H
HexUserHex2020-04-15 19:21:45
bash
HexUserHex, 2020-04-15 19:21:45

What is the easiest and fastest way to parse this file?

Good afternoon,
tell me the easiest way to parse this file on bash

xxx:[<b>yyyyy1</b>] yyy:[xxxx]
xxx:[<b>yyyyy2</b>] yyy:[xxxx]
....


As a result, you need to get:
yyyyy1
yyyyy2

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2020-04-15
@HexUserHex

grep/sed

$ printf "xxx:[<b>yyyyy1</b>] yyy:[xxxx]\nxxx:[<b>yyyyy2</b>] yyy:[xxxx]" | grep -oE '<b>+</b>' | sed -E 's/<\/?b>//g'

yyyyy1
yyyyy2

perl one-liner:
$ printf "xxx:[<b>yyyyy1</b>] yyy:[xxxx]\nxxx:[<b>yyyyy2</b>] yyy:[xxxx]" | perl -e 'while(<>){ if ($_ =~ m/<b>(.*)<\/b>/){ print $1."\n"; } }'
yyyyy1
yyyyy2

V
Viktor Taran, 2020-04-15
@shambler81

cat /tmp/33.sh | egrep -o "<b>\w+" | sed 's/<b>//g'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question