0% found this document useful (0 votes)
3 views10 pages

Shell Scripting Basics and Variables

Uploaded by

mrunknown9981
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

Shell Scripting Basics and Variables

Uploaded by

mrunknown9981
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Shell scripts

1. Automating daily tasks


2. Automating repetitive tasks
3. Customizing work environment
4. Executing system procedures
Shell scripts

1. Interactive

2. Non-interactive (cron jobs)


Shell scripts
1. First line of script #!/bin/bash
2. # beginning is always taken
comment
3. Make script executable $chmod
700 <file>
4. No compilers required
Shell variables

1. Combination of alphabets
2. No commas or blanks
3. First character must be alphabet
4. Variables are case-sensitive
5. Variables can be of any length
Shell variables

1. name, Name, NAME are different


2. si_int, m_hra are valid
3. 123, 345 are not valid
4. Variables are assigned with “=“
5. user defined and system variables
Shell variables

1. HOME, LOGNAME PATH are


system variables
2. a=10, b=15 are user defined
variables
Shell variables

1. variable die after shell execution


2. s=20 here 20 is treated as string
3. a=“”, a=‘’, a= are null variables
4. Shell ignores null variables
echo command

$name=johny age=20
echo $name $age

Output: johny 10
Arithmetic in shells

$a=20 b=30
echo `expr $a+$b`
echo `expr $a-$b
echo `expr $a\*$b`
echo `expr $a/$b`

You might also like