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?
Asked
Active
Viewed 1.3k times
1
-
1Or 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
-
1Your 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 and a shell (or command-line interface). You should learn about them. – glenn jackman Mar 21 '16 at 20:04
1 Answers
11
$ if [ 'a' = 'b' ]; then echo 'Equal'; else echo 'Not equal'; fi
Not equal
$

Gunnar Hjalmarsson
- 33,540
- 3
- 64
- 94