Skip to content
Advertisement

Bash parse output in route command

I am writing a bash script to register the remote hosts in a wireless network. I am getting the remote IPs, but I need help to parse the output. Here’s my output:

JavaScript

I need to get these IPs and insert into a command like ... <remote_ip_1> ...

How can it be done? I couldn’t find this case in the answers.

Thank you

Advertisement

Answer

You could use something like

JavaScript

We are negating the use of grep and using // to search for the text required and then the awk system function to execute a command along with $1

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement