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 do I use the CLI to configure Zabbix?
- How can I use cli sed to deploy an ARM template?
- How do I use sed to add quotes around a string in a command line interface?
- How can I grant permission to use the CLI sed command?
- How can I use the 'sed' command line utility to add quotes around a string?
- How to use sed to modify Kubernetes configuration files from the command line?
- How can I use CLI sed and Yarn together to develop software?
- How can I use sed in a CLI for Kubernetes?
- What is the difference between using sed in a command line interface and a graphical user interface?
- How do I delete a line using the command line sed tool?
See more codes...