I have a telnet command which prints hundreds of lines of output, Can I grep the output?
Use the 'script' command. If you run 'script ' before running telnet, all text that gets written to the terminal also gets written to /file/path/filename. You'll have to do 'exit' or Ctrl-D to actually write to the file or you can keep a check on the file.
Finally grep on the file using filename | grep "search text"
/file/path/filename is the path where you want to store the output of telnet.
Using script command
script /tmp/myscript.txt
then all the commands you fire in terminal and the output will go in this file. use ctrl + D when you are done, which will write to the file.
Do a grep on this file.
cat /tmp/myscript.txt | grep "textToSearch"
Use tee
command to redirect the content to file:
telnet google.com 80 | tee outfile
Then grep the file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With