Giter VIP home page Giter VIP logo

exercises's Introduction

exercises

exercises shell script

Execise 4:

see also http://www.basiclinuxcommand.com/linux-command/shopt.html for linux command shopt

Aliases are not expanded when the shell is not interactive, unless the expand_aliases option is set using the shopt shell built-in.

Exercise 5:

The following string operators are supported by Bourne Shell.

Assume variable a holds "abc" and variable b holds "efg" then โˆ’

Operator Description Example = Checks if the value of two operands are equal or not; if yes, then the condition becomes true. [ $a = $b ] is not true. != Checks if the value of two operands are equal or not; if values are not equal then the condition becomes true. [ $a != $b ] is true. -z Checks if the given string operand size is zero; if it is zero length, then it returns true. [ -z $a ] is not true. -n Checks if the given string operand size is non-zero; if it is nonzero length, then it returns true. [ -n $a ] is not false. str Checks if str is not the empty string; if it is empty, then it returns false. [ $a ] is not false.

See also: http://www.tutorialspoint.com/unix/unix-string-operators.htm

Exercise 7:

Array displaying wrong names and wrong number of array elemts could be corrected with following code

-get length of the array

ArrayLenght=${#PLAYERS[@]}

-Loop to display all player names

for (( i=0; i<$ArrayLenght; i++ )); do echo "Hello ${PLAYERS[$i]}. Good Luck for the football game!" done

exercises's People

Contributors

tamimzia avatar

exercises's Issues

Array showing empty elements

user@tamimzia1:~/scripts$ ./exec7.sh

0: Hello Obaidullah Karimi. Good Luck for the Game!
1: Hello Farid Ahmadi. Good Luck for the Game!
2: Hello Shamsuddin Amiri. Good Luck for the Game!
3: Hello Mansur Faqiryar. Good Luck for the Game!
4: Hello Qays Shayesteh. Good Luck for the Game!
5: Hello Hafizullah Qadami. Good Luck for the Game!
6: Hello Ata Yamrali. Good Luck for the Game!
7: Hello Abdul Salem Jamshid. Good Luck for the Game!
8: Hello Mohammad Fazel Bratyan. Good Luck for the Game!
9: Hello Israfeel Kohistani. Good Luck for the Game!
10: Hello Mohammad Nader Aimi. Good Luck for the Game!
11: Hello . Good Luck for the Game!
12: Hello . Good Luck for the Game!
13: Hello . Good Luck for the Game!
14: Hello . Good Luck for the Game!
15: Hello . Good Luck for the Game!
16: Hello . Good Luck for the Game!
17: Hello . Good Luck for the Game!
18: Hello . Good Luck for the Game!
19: Hello . Good Luck for the Game!
20: Hello . Good Luck for the Game!
21: Hello . Good Luck for the Game!
22: Hello . Good Luck for the Game!
23: Hello . Good Luck for the Game!
24: Hello . Good Luck for the Game!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.