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.shto produce messages to the topic. For example,bin/kafka-console-producer.sh --broker-list localhost:9092 --topic <topic_name> -
Use
bin/kafka-console-consumer.shto consume the messages from the topic. For example,bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic <topic_name> --from-beginning -
Use
sedto 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.shto 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.shto 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 a Windows command line interface?
- How do I use the CLI to configure Zabbix?
- How can I use the command line tool sed to create a tutorial?
- How can I use the command line to edit text using Qt?
- How can I use the command line to compress and edit files with sed and zip?
- replace text
- How can I use sed command line options to modify text files?
- How do I use the command line to edit text using sed?
- How can I set up the Xcode command line interface?
- How can I use the sed command in the Ubuntu command line interface?
See more codes...