grepifconfig

"Command not found" in ifconfig | grep IF statement


I'm trying to check if my ethernet adapter is hardwired. For that I have the following secton in my code:

if 'ifconfig | grep "status: active" | head -2 | tail -1 | awk {'print$2'} | cut -f1 -d:'; then
  wired_status=True
  echo $wired_status

For this section of code it gives the following error:

./tst_wired.sh: line 27: ifconfig | grep "status: active" | head -2 | tail -1 | awk {print} | cut -f1 -d:: command not found

Typing "ifconfig" in my terminal is recognized and works.


Solution

  • Looks like you've used apostrophe instead of backtick characters:

    ` and ' are different