bash | read variable

Many shell variables are inherited from the login shell
Environment. In other words, they are preset variables

For example, when running a script the following
Variables will be available (amongst others):
-HOME
-PATH
-LOGNAME
-TERM

echo $LOGNAME --> iam user

Such variables may be changed by the script, but the
changes will not be seen by the login shell unless the
script was run using the "." operator.

llist=`who | sort` #shell command
echo $llist

llist=who | sort #string

echo the date is `date +%m/%d/%y` today


Groupping commands:
(
ls
date
)

Please enter your name: ; read name
Tom and Jerry
echo $name
Tom and Jerry
Please enter your name: $name

This command is split \
over several lines

-------
Conditional code

True and False
-When every UNIX command completes, it invisibly
Returns a value to the program that started it (usually the shell)
Informing that program of the "status" of completiono f the command

- This value is a number, and is known as the exit status of a command

-This value is usually ignored (by the shell and by the user)

-Typically,an exit status of 0 means that the program completed with NO ERROR
conditions arising, while an exit status of some other number means that some
error has occurred

-This exit status is stored in the built-in variable called "?", and can be examined
at any time with the command:
echo $?

- The contents of this variable are updated every time a program runs
(including the -- echo command above)

- It is often useful for shell programmers to think of an exit status
of 0 as being equivalent to the logical term True,
and for any other exit status to be equivalent to False

- Note that this is exactly the opposite to the way some programming
languages (e.g.C ) threat true and false

-There even exist UNIX programs called TRUE and FALSE that
Demonstrate the use of these conventions


$false
echo $? --> 1
$true
echo $? --> 0

Comments

Popular posts from this blog

HAproxy logging

teamcity Automatic Agent Start under Linux

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all