cli-sedHow to use CLI sed to modify data in a Kafka topic?
Using sed
in the command line interface (CLI) to modify data in a Kafka topic requires the following steps:
-
Create a Kafka topic with the command
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic <topic_name>
-
Use
bin/kafka-console-producer.sh
to produce messages to the topic. For example,bin/kafka-console-producer.sh --broker-list localhost:9092 --topic <topic_name>
-
Use
bin/kafka-console-consumer.sh
to consume the messages from the topic. For example,bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic <topic_name> --from-beginning
-
Use
sed
to modify the data. For example,bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic <topic_name> --from-beginning | sed 's/old_text/new_text/g'
-
Use
bin/kafka-console-producer.sh
to produce the modified messages to the topic. For example,bin/kafka-console-producer.sh --broker-list localhost:9092 --topic <topic_name> < modified_message
-
Use
bin/kafka-console-consumer.sh
to consume the modified messages from the topic. For example,bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic <topic_name> --from-beginning
-
Verify that the messages have been modified correctly.
Example code block:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic <topic_name> --from-beginning | sed 's/old_text/new_text/g'
Output (if any):
modified_message
Helpful links
More of Cli Sed
- How can I use sed in the command line on macOS?
- How do I use the CLI to configure Zabbix?
- How can I use SED in a Windows command line interface?
- How can I use the command line to compress and edit files with sed and zip?
- How do I use sed to insert a new line in a command line interface?
- How do I use the command line to compress a file using SED and ZIP?
- How can I use sed in a command line interface?
- How can I use the sed command in the Ubuntu command line interface?
- How can I use cli sed to select an Azure subscription?
- How can I use CLI sed to authenticate to AWS?
See more codes...