Answer the question
In order to leave comments, you need to log in
How to execute a command in Linux with a parameter taken from the stdout of the previous command?
Hello, I got confused by this question after I wanted to wake up my home computer using etherwake by sending a magic-packet to the mac-address of the computer. Since I don't remember the mac-address by heart, I took it from /etc/config/dhcp
with tail -n2 /etc/config/dhcp | head-n1 | tr -s " " | tr -d \' | cut -f3 -d " "
Got a mac in stdout, but how do I substitute it? etherwake -i br-lan "my mac address".
Answer the question
In order to leave comments, you need to log in
MY_MAC=$(tail -n2 | head -n1 | tr -s " " | tr -d \' | cut -f3 -d " ")
etherwake -i br-lan "$MY_MAC"
etherwake -i br-lan `ваша команда получения мака`
or
In the first case, everything in dashes will first be replaced by the result of the script, in the second case, a new variable will be created.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question