Linux Tutorials
Building Hadoop Clusters On Linux In EC2
Installing And Using Hadoop
Setting Up SSH Keys Using SSH Agents And Tunnels
Creating OpenSSL Certificates and Certificate Authorities
Installing and configuring Xen
IPTables Primer
Linux Basic Bash Scripting

Linux Basic Bash Scripting

Variables

Variables are used for storing data in your script. With linux scripting you only use the $ at the beginning of the variable when calling it not when declaring the variable. It is common practice in shell scripting to name your variables with all capital letters. The = is used to set a variable.

Examples:
FIRSTNAME=Bob -- Sets variable FIRSTNAME to Bob
LASTNAME=Jones -- Sets variable LASTNAME to Jones
FULLNAME="$FIRSTNAME $LASTNAME" -- Sets variable FULLNAME to Bob Jones by referencing the variables FIRSTNAME and LASTNAME.

If you need to reference a variable in a string with characters attached to the value of the variable reference the variable with {} surrounding the variable name.

Example:
echo "${VARIABLE}s"

Built In Variables

The Bash shell has many built in variables to make life easy for us.

BASH_VERSION -- Version of bash shell currently being used.
EUID -- Effective user ID of the current user.
GROUPS -- An array variable storing the list of groups the current user is a member of.
HOSTNAME -- contains the name of the current host.
PWD -- The present working directory.
RANDOM -- When referenced generates a random number between 0-32767. Giving RANDOM a value seeds the random number generator.
SECONDS -- The number of seconds since the shell was started.
UID -- The real UID of the current user.

Basic Syntax <<  1 2 3 4 5  >> Conditional Statements
New Content