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 do I use the CLI to configure Zabbix?
- How can I use sed in a command line interface?
- 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 can I use cli sed to configure credentials?
- How can I use sed to manipulate a JSON file from the command line?
- How can I troubleshoot when my CLI sed command is not working?
- How do I use the command line to compress a file using SED and ZIP?
- replace text
- How do I use sed to add quotes around a string in a command line interface?
See more codes...