I'm relatively new to Bash scripting but I'm very familiar with Python and many Bash commands. I was wondering if it's possible to use a command such as ifconfig eno1
and use the output as a condition to be used in an if
statement. Basically, if you issue:
ifconfig eno1
and you get an active IP, is there any way to save the output of that to a variable as a 1/0 or true/false, to be used in the following if
statement example (assuming ifoutput
is the variable name):
if [ "$ifoutput" == "$True"]
then
echo connection is active!
fi
I thought of possibly calling a Python script that does essentially the same thing, however I was thinking I would run into the same issue; being no way to get an individual return value from the Python script to be used in the if
statement. Please advise and please go easy on me -- as I said I am relatively new to Bash scripting! I already have methods of doing this strictly using Python, however I am trying to learn more about Bash scripting. Thanks in advance!
> filename.txt
or pipe it to a different command,| nextCommand
.