1

I was asked to create command which generates one word in terminal, if internet connection is absense, and another one, if it present. For doing that it seems that I need "if" and "else" syntaxis. Is it possible to provide such syntaxis in terminal?

muru
  • 193,181
  • 53
  • 473
  • 722
John Taylor
  • 147
  • 1
  • 1
  • 7
  • 1
    Or see http://askubuntu.com/questions/58385/help-on-if-else-in-shell, and http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-6.html – muru Mar 21 '16 at 17:51
  • @muru : I'm the newbie in Ubuntu, and I think that the bash is something different than terminal. My question is about terminal. – John Taylor Mar 21 '16 at 17:51
  • 1
    Your terminal runs bash. See http://askubuntu.com/q/506510/158442 and http://askubuntu.com/q/111144/158442 – muru Mar 21 '16 at 17:53
  • 1
    @JohnTaylor ok, but the terminal understands bash ;-) – Rinzwind Mar 21 '16 at 17:57
  • Bash essentially is the command prompt that runs in the terminal. You better start learning bash scripting cuz that's what you essentially want – Sergiy Kolodyazhnyy Mar 21 '16 at 17:59
  • @JohnTaylor, there is a fundamental difference between a [terminal](https://en.wikipedia.org/wiki/Terminal_emulator) and a [shell (or command-line interface)](https://en.wikipedia.org/wiki/Command-line_interface). You should learn about them. – glenn jackman Mar 21 '16 at 20:04

1 Answers1

11
$ if [ 'a' = 'b' ]; then echo 'Equal'; else echo 'Not equal'; fi
Not equal
$
Gunnar Hjalmarsson
  • 32,938
  • 3
  • 63
  • 94