L
L
lergus2020-12-14 14:15:51
bash
lergus, 2020-12-14 14:15:51

How to pipe data in bash?

I'm trying to get a list of empty groups in kafka and process it, or at least save it to a file.
i use the command

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --all-groups | grep "has no active members"

And I get in the output
Consumer group 'configuration.task1' has no active members.

Consumer group 'configuration.task2' has no active members.

Consumer group 'configuration.task3' has no active members.

When I try to display only the name of the groups, I still get the full list
./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --all-groups | grep has no active members | cut -d" " -f3 Saving

data to a file also fails, the output remains in the console and is not contained in the file
./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --all-groups | grep "has no active members" &> ~/123.test

What am I doing wrong?)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2020-12-14
@saboteur_kiev

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --all-groups | grep -oP "'\K.*(?=' has no active members)"

H
hint000, 2020-12-14
@hint000

cut parameters need to be corrected:

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --all-groups | grep has no active members | cut -d\' -f2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question