Skip to content
Advertisement

Combining two bash commands

If found this code

JavaScript

which gives pi Ip address

and this

JavaScript

which sends 1.2.3.4 off to dweet.io stream

How can I get the output from 1st to replace the 1.2.3.4 in second please?

Advertisement

Answer

Save the output of the first command in a variable:

JavaScript

Btw, if your raspberrypi is running raspbian, then a much cleaner way to get the IP address:

JavaScript

Simplifying the commands to:

JavaScript

Making that a one-liner:

JavaScript

UPDATE

So it seems hostname -I gives a bit different output for you. You can use this then:

JavaScript

To make it a one-liner, you can insert this into the second line just like I did in the earlier example.

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