You should also investigate the -p option to rostopic echo, to see if it can do what you need: rostopic echo -p /my_topic