SlideShare a Scribd company logo
1
Shell Scripting
Vibrant technology
&
Computers
www.vibranttechnologies.co.in
www.vibranttechnologies.co.in 2
3
Outline
 What is shell?
 Basic
 Syntax
 Lists
 Functions
 Command Execution
 Here Documents
 Debug
 Regular Expression
 Find
www.vibranttechnologies.co.in
4
Why Shell?
 The commercial UNIX used Korn Shell
 For Linux, the Bash is the default
 Why Shell?
 For routing jobs, such as system administration, without
writing programs
 However, the shell script is not efficient, therefore, can
be used for prototyping the ideas
 For example,
% ls –al | more (better format of listing
directory)
% man bash | col –b | lpr (print man page of man)
www.vibranttechnologies.co.in
5
What is Shell?
 Shell is the interface between end user
and the Linux system, similar to the
commands in Windows
 Bash is installed as in /bin/sh
 Check the version
% /bin/sh --version
Kernel
Other
programs
X window
bash
csh
www.vibranttechnologies.co.in
6
Pipe and Redirection
 Redirection (< or >)
% ls –l > lsoutput.txt (save output to lsoutput.txt)
% ps >> lsoutput.txt (append to lsoutput.txt)
% more < killout.txt (use killout.txt as parameter to
more)
% kill -l 1234 > killouterr.txt 2 >&1 (redirect to the
same file)
% kill -l 1234 >/dev/null 2 >&1 (ignore std output)
 Pipe (|)
 Process are executed concurrently
% ps | sort | more
% ps –xo comm | sort | uniq | grep –v sh | more
% cat mydata.txt | sort | uniq | > mydata.txt
(generates an empty file !)
www.vibranttechnologies.co.in
7
Shell as a Language
 We can write a script containing many shell commands
 Interactive Program:
 grep files with POSIX string and print it
% for file in *
> do
> if grep –l POSIX $file
> then
> more $file
 fi
 done
Posix
There is a file with POSIX in it
 ‘*’ is wildcard
% more `grep –l POSIX *`
% more $(grep –l POSIX *)
% more –l POSIX * | more
www.vibranttechnologies.co.in
8
Writing a Script
 Use text editor to generate the “first” file
#!/bin/sh
# first
# this file looks for the files containing POSIX
# and print it
for file in *
do
if grep –q POSIX $file
then
echo $file
fi
done
exit 0
% /bin/sh first
% chmod +x first
%./first (make sure . is include in PATH
parameter)
exit code, 0 means successful
www.vibranttechnologies.co.in
9
Syntax
 Variables
 Conditions
 Control
 Lists
 Functions
 Shell Commands
 Result
 Document
www.vibranttechnologies.co.in
10
Variables
 Variables needed to be declared, note it is case-sensitive
(e.g. foo, FOO, Foo)
 Add ‘$’ for storing values
% salutation=Hello
% echo $salutation
Hello
% salutation=7+5
% echo $salutation
7+5
% salutation=“yes dear”
% echo $salutation
yes dear
% read salutation
Hola!
% echo $salutation
Hola!
www.vibranttechnologies.co.in
11
Quoting
 Edit a “vartest.sh” file
#!/bin/sh
myvar=“Hi there”
echo $myvar
echo “$myvar”
echo `$myvar`
echo $myvar
echo Enter some text
read myvar
echo ‘$myvar’ now equals $myvar
exit 0
Output
Hi there
Hi there
$myvar
$myvar
Enter some text
Hello world
$myvar now equals Hello world
www.vibranttechnologies.co.in
12
Environment Variables
 $HOME home directory
 $PATH path
 $PS1 第一層提示符號 (normally %)
 $PS2 第二層提示符號 (normally >)
 $$ process id of the script
 $# number of input parameters
 $0 name of the script file
 $IFS separation character (white
space)
 Use ‘env’ to check the valuewww.vibranttechnologies.co.in
13
Parameter
% IFS = ` `
% set foo bar bam
% echo “$@”
foo bar bam
% echo “$*”
foo bar bam
% unset IFS
% echo “$*”
foo bar bam
doesn’t matter IFS
www.vibranttechnologies.co.in
14
Condition
 test or ‘ [ ‘
if test –f fred.c
then
...
fi
If [ -f
fred.c ]
then
...
fi
if [ -f fred.c ];then
...
fi
expression1 –eq expression2
expression1 –ne expression2
expression1 –gt expression2
expression1 –ge expression2
expression1 -lt expression2
expression1 –le expression2
!expression
-d file if directory
-e file if exist
-f file if file
-g file if set-group-id
-r file if readable
-s file if size >0
-u file if set-user-id
-w file if writable
-x file if executableString1 = string2
String1 != string 2
-n string (if not empty string)
-z string (if empty string)
need space !
www.vibranttechnologies.co.in
15
Control Structure
Syntax
if condition
then
statement
else
statement
fi
#!/bin/sh
echo “Is it morning? Please answer yes or no”
read timeofday
if [ $timeofday = “yes” ]; then
echo “Good morning”
else
echo “Good afternoon”
fi
exit 0
Is it morning? Please answer yes or no
yes
Good morning
www.vibranttechnologies.co.in
16
Condition Structure
#!/bin/sh
echo “Is it morning? Please answer yes or no”
read timeofday
if [ $timeofday = “yes” ]; then
echo “Good morning”
elif [ $timeofday = “no” ]; then
echo “Good afternoon”
else
echo “Sorry, $timeofday not recongnized. Enter yes or no”
exit 1
fi
exit 0
www.vibranttechnologies.co.in
17
Condition Structure
#!/bin/sh
echo “Is it morning? Please answer yes or no”
read timeofday
if [ “$timeofday” = “yes” ]; then
echo “Good morning”
elif [ $timeofday = “no” ]; then
echo “Good afternoon”
else
echo “Sorry, $timeofday not recongnized. Enter yes or no”
exit 1
fi
exit 0
If input “enter” still returns Good morning
www.vibranttechnologies.co.in
18
Loop Structure
Syntax
for variable
do
statement
done
#!/bin/sh
for foo in bar fud 43
do
echo $foo
done
exit 0
bar
fud
43
How to output as bar fud 43?
Try change for foo in “bar fud 43”
This is to have space in variable
www.vibranttechnologies.co.in
19
Loop Structure
 Use wildcard ‘*’
#!/bin/sh
for file in $(ls f*.sh); do
lpr $file
done
exit 0
Print all f*.sh files
www.vibranttechnologies.co.in
20
Loop Structure
Syntax
while condition
do
statement
done
#!/bin/sh
for foo in 1 2 3 4 5 6 7 8 9 10
do
echo “here we go again”
done
exit 0
#!/bin/sh
foo = 1
while [ “$foo” –le 10 ]
do
echo “here we go again”
foo = $foo(($foo+1))
done
exit 0
Syntax
until condition
do
statement
done
Note: condition is
Reverse to while
How to re-write
previous sample?
www.vibranttechnologies.co.in
21
Case Statement
Syntax
case variable in
pattern [ | pattern ] …) statement;;
pattern [ | pattern ] …) statement;;
…
esac
#!/bin/sh
echo “Is it morning? Please answer yes or no”
read timeofday
case “$timeofday” in
yes) echo “Good Morning”;;
y) echo “Good Morning”;;
no) echo “Good Afternoon”;;
n) echo “Good Afternoon”;;
* ) echo “Sorry, answer not recongnized”;;
esac
exit 0
www.vibranttechnologies.co.in
22
Case Statement
 A much “cleaner” version
#!/bin/sh
echo “Is it morning? Please answer yes or no”
read timeofday
case “$timeofday” in
yes | y | Yes | YES ) echo “Good Morning”;;
n* | N* ) echo “Good Afternoon”;;
* ) echo “Sorry, answer not recongnized”;;
esac
exit 0
But this has a problem, if we enter ‘never’ which obeys n*
case and prints “Good Afternoon”
www.vibranttechnologies.co.in
23
Case Statement
#!/bin/sh
echo “Is it morning? Please answer yes or no”
read timeofday
case “$timeofday” in
yes | y | Yes | YES )
echo “Good Morning”
echo “Up bright and early this morning”
;;
[nN]*)
echo “Good Afternoon”;;
*)
echo “Sorry, answer not recongnized”
echo “Please answer yes of no”
exit 1
;;
esac
exit 0
www.vibranttechnologies.co.in
24
List
 AND (&&)
statement1 && statement2 && statement3 …
#!/bin/sh
touch file_one
rm –f file_two
if [ -f file_one ] && echo “Hello” && [-f file_two] && echo “ there”
then
echo “in if”
else
echo “in else”
fi
exit 0
Output
Hello
in else
Check if file exist if not then create one
Remove a file
www.vibranttechnologies.co.in
25
List
 OR (||)
statement1 || statement2 || statement3 …
#!/bin/sh
rm –f file_one
if [ -f file_one ] || echo “Hello” || echo “ there”
then
echo “in if”
else
echo “in else”
fi
exit 0
Output
Hello
in else
www.vibranttechnologies.co.in
26
Statement Block
 Use multiple statements in the same place
get_comfirm && {
grep –v “$cdcatnum” $stracks_file > $temp_file
cat $temp_file > $tracks_file
echo
add_record_tracks
}
www.vibranttechnologies.co.in
27
Function
 You can define functions for “structured” scripts
function_name() {
statements
}
#!/bin/sh
foo() {
echo “Function foo is executing”
}
echo “script starting”
foo
echo “script ended”
exit 0
Output
script starting
Function foo is executing
Script ended
You need to define a function before using it
The parameters $*,$@,$#,$1,$2 are replaced by local value
if function is called and return to previous after function is finished
www.vibranttechnologies.co.in
28
Function
#!/bin/sh
sample_text=“global variable”
foo() {
local sample_text=“local variable”
echo “Function foo is executing”
echo $sample_text
}
echo “script starting”
echo $sample_text
foo
echo “script ended”
echo $sample_text
exit 0
define local
variable
Output?
Check the
scope of
the
variables
www.vibranttechnologies.co.in
29
Function
 Use return to pass a result
#!/bin/sh
yes_or_no() {
echo “Is your name $* ?”
while true
do
echo –n “Enter yes or no:”
read x
case “$x” in
y | yes ) return 0;;
n | no ) return 1;;
* ) echo “Answer yes or no”
esac
done
}
echo “Original parameters are $*”
if yes_or_no “$1”
then
echo “Hi $1, nice name”
else
echo “Never mind”
fi
exit 0
Output
./my_name John Chuang
Original parameters are John Chuang
Is your name John?
Enter yes or no: yes
Hi John, nice name.
www.vibranttechnologies.co.in
30
Command
 External:
use interactively
 Internal:
 only in script
 break
skip loop
#!/bin/sh
rm –rf fred*
echo > fred1
echo > fred2
mkdir fred3
echo > fred4
for file in fred*
do
if [ -d “$file” ] ; then
break;
fi
done
echo first directory starting fred was $file
rm –rf fred*
exit 0
www.vibranttechnologies.co.in
31
Command
 : treats it as true
#!/bin/sh
rm –f fred
if [ -f fred ]; then
:
else
echo file fred did not exist
fi
exit 0
www.vibranttechnologies.co.in
32
Command
 continue continues next iteration
#!/bin/sh
rm –rf fred*
echo > fred1
echo > fred2
mkdir fred3
echo > fred4
for file in fred*
do
if [ -d “$file” ]; then
echo “skipping directory $file”
continue
fi
echo file is $file
done
rm –rf fred*
exit 0
www.vibranttechnologies.co.in
33
Command
 . ./shell_script execute shell_script
classic_set
#!/bin/sh
verion=classic
PATH=/usr/local/old_bin:/usr/bin:/bin:.
PS1=“classic> ”
latest_set
#!/bin/sh
verion=latest
PATH=/usr/local/new_bin:/usr/bin:/bin:.
PS1=“latest version> ” % . ./classic_set
classic> echo $version
classic
Classic> . latest_set
latest
latest version>
www.vibranttechnologies.co.in
34
Command
 echo print string
 -n do not output the trailing newline
 -e enable interpretation of backslash escapes
 0NNN the character whose ACSII code is NNN
  backslash
 a alert
 b backspace
 c suppress trailing newline
 f form feed
 n newline
 r carriage return
 t horizontal tab
 v vertical tab Try these
% echo –n “string to n output”
% echo –e “string to n output”
www.vibranttechnologies.co.in
35
Command
 eval evaluate the value of a parameter
similar to an extra ‘$’
% foo=10
% x=foo
% y=‘$’$x
% echo $y
Output is $foo
% foo=10
% x=foo
% eval y=‘$’$x
% echo $y
Output is 10
www.vibranttechnologies.co.in
36
Command
 exit n ending the script
 0 means success
 1 to 255 means specific error code
 126 means not executable file
 127 means no such command
 128 or >128 signal
#!/bin/sh
if [ -f .profile ]; then
exit 0
fi
exit 1
Or % [ -f .profile ] && exit 0 || exit 1
www.vibranttechnologies.co.in
37
Command
 export gives a value to a parameter
This is ‘export2’
#!/bin/sh
echo “$foo”
echo “$bar”
This is ‘export1’
#!/bin/sh
foo=“The first meta-syntactic variable”
export bar=“The second meta-syntactic variable”
export2
Output is
%export1
The second-syntactic variable
%
www.vibranttechnologies.co.in
38
Command
 expr evaluate expressions
%x=`expr $x + 1` (Assign result value expr $x+1 to x)
Also can be written as
%x=$(expr $x + 1)
Expr1 | expr2 (or) expr1 != expr2
Expr1 & expr2 (and) expr1 + expr2
Expr1 = expr2 expr1 – expr2
Expr1 > expr2 expr1 * expr2
Expr1 >= expr2 expr1 / expr2
Expr1 < expr2 expr1 % expr2 (module)
Expr1 <= expr2 www.vibranttechnologies.co.in
39
Command
 printf format and print data
 Escape sequence
  backslash
 a beep sound
 b backspace
 f form feed
 n newline
 r carriage return
 t tab
 v vertical tab
 Conversion specifier
 %d decimal
 %c character
 %s string
 %% print %
% printf “%sn” hello
Hello
% printf “%s %dt%s” “Hi
There” 15 people
Hi There 15 people
www.vibranttechnologies.co.in
40
Command
 return return a value
 set set parameter variable
#!/bin/sh
echo the date is $(date)
set $(date)
echo The month is $2
exit 0
www.vibranttechnologies.co.in
41
Command
 Shift shift parameter once, $2 to $1, $3 to
$2, and so on
#!/bin/sh
while [ “$1” != “” ]; do
echo “$1”
shift
done
exit 0
www.vibranttechnologies.co.in
42
Command
 trap action after receiving signal
trap command signal
 signal explain
HUP (1) hung up
INT (2) interrupt (Crtl + C)
QUIT (3) Quit (Crtl + )
ABRT (6) Abort
ALRM (14) Alarm
TERM (15) Terminate
www.vibranttechnologies.co.in
43
Command
#!/bin/sh
trap ‘rm –f /tmp/my_tmp_file_$$’ INT
echo creating file /tmp/my_tmp_file_$$
date > /tmp/my_tmp_file_$$
echo “press interrupt (CTRL-C) to interrupt …”
while [ -f /tmp/my_tmp_file_$$ ]; do
echo File exists
sleep 1
done
echo The file no longer exists
trap INT
echo creating file /tmp/my_tmp_file_$$
date > /tmp/my_tmp_file_$$
echo “press interrupt (CTRL-C) to interrupt …”
while [ -f /tmp/my_tmp_file_$$ ]; do
echo File exists
sleep 1
done
echo we never get there
exit 0 www.vibranttechnologies.co.in
44
Command
creating file /tmp/my_file_141
press interrupt (CTRL-C) to interrupt …
File exists
File exists
File exists
File exists
The file no longer exists
Creating file /tmp/my_file_141
Press interrupt (CTRL-C) to interrupt …
File exists
File exists
File exists
File exists
www.vibranttechnologies.co.in
45
Command
Unset remove parameter or function
#!/bin/sh
foo=“Hello World”
echo $foo
unset $foo
echo $foo
www.vibranttechnologies.co.in
46
Pattern Matching
 find search for files in a directory hierarchy
find [path] [options] [tests] [actions]
options
-depth find content in the directory
-follow follow symbolic links
-maxdepths N fond N levels directories
-mount do not find other directories
tests
-atime N accessed N days ago
-mtime N modified N days ago
-new otherfile name of a file
-type X file type X
-user username belong to username
www.vibranttechnologies.co.in
47
Pattern Matching
operator
! -not test reverse
-a -and test and
-o -or test or
action
-exec command execute command
-ok command confirm and exectute command
-print print
-ls ls –dils
Find files newer than while2 then print
% find . –newer while2 -print
www.vibranttechnologies.co.in
48
Pattern Matching
Find files newer than while2 then print only files
% find . –newer while2 –type f –print
Find files either newer than while2, start with ‘_’
% find . ( -name “_*” –or –newer while2 ) –type f
–print
Find files newer than while2 then list files
% find . –newer while2 –type f –exec ls –l {} ;
www.vibranttechnologies.co.in
49
Pattern Matching
 grep print lines matching a pattern
(General Regular Expression Parser)
grep [options] PATTERN [FILES]
option
-c print number of output context
-E Interpret PATTERN as an extended regular expression
-h Supress the prefixing of filenames
-i ignore case
-l surpress normal output
-v invert the sense of matching
% grep in words.txt
% grep –c in words.txt words2.txt
% grep –c –v in words.txt words2.txt
www.vibranttechnologies.co.in
50
Regular Expressions
 a regular expression (abbreviated as regexp or regex, with
plural forms regexps, regexes, or regexen) is a string that
describes or matches a set of strings, according to certain syntax
rules.
 Syntax
 ^ Matches the start of the line
 $ Matches the end of the line
 . Matches any single character
 [] Matches a single character that is contained within the
brackets
 [^] Matches a single character that is not contained within the
brackets
 () Defines a "marked subexpression”
 {x,y}Match the last "block" at least x and not more than y
times
www.vibranttechnologies.co.in
51
Regular Expressions
 Examples:
 ".at" matches any three-character string like
hat, cat or bat
 "[hc]at" matches hat and cat
 "[^b]at" matches all the matched strings from
the regex ".at" except bat
 "^[hc]at" matches hat and cat but only at the
beginning of a line
 "[hc]at$" matches hat and cat but only at the
end of a line
www.vibranttechnologies.co.in
52
Regular Expressions
 POSIX class similar to meaning
 [:upper:] [A-Z] uppercase letters
 [:lower:] [a-z] lowercase letters
 [:alpha:] [A-Za-z] upper- and lowercase letters
 [:alnum:] [A-Za-z0-9] digits, upper- and lowercase
letters
 [:digit:] [0-9] digits
 [:xdigit:] [0-9A-Fa-f] hexadecimal digits
 [:punct:] [.,!?:...] punctuation
 [:blank:] [ t] space and TAB characters only
 [:space:] [ tnrfv]blank (whitespace) characters
 [:cntrl:] control characters
 [:graph:] [^ tnrfv] printed characters
 [:print:] [^tnrfv] printed characters and space
 Example: [[:upper:]ab] should only match the uppercase letters
and lowercase 'a' and 'b'.
www.vibranttechnologies.co.in
53
Regular Expressions
 POSIX modern (extended) regular
expressions
 The more modern "extended" regular expressions
can often be used with modern Unix utilities by
including the command line flag "-E".
 + Match one or more times
 ? Match at most once
 * Match zero or more
 {n} Match n times
 {n,} Match n or more times
 {n,m} Match n to m times
www.vibranttechnologies.co.in
54
Regular Expressions
 Search for lines ending with “e”
% grep e$ words2.txt
 Search for “a”
% grep a[[:blank:]] word2.txt
 Search for words starting with “Th.”
% grep Th.[[:blank:]] words2.txt
 Search for lines with 10 lower case characters
% grep –E [a-z]{10} words2.txt
www.vibranttechnologies.co.in
55
Command
 $(command) to execute command in a script
 Old format used “`” but it can be confused with
“’”
#!/bin/sh
echo The current directory is $PWD
echo the current users are $(who)
www.vibranttechnologies.co.in
56
Arithmetic Expansion
 Use $((…)) instead of expr to evaluate arithmetic equation
#!/bin/sh
x=0
while [ “$x” –ne 10]; do
echo $x
x=$(($x+1))
done
exit 0
www.vibranttechnologies.co.in
57
Parameter Expansion
 Parameter Assignment
foo=fred
echo $foo
#!/bin/sh
for i in 1 2
do
my_secret_process ${i}_tmp
done
#!/bin/sh
for i in 1 2
do
my_secret_process $i_tmp
done
Gives result
“mu_secret_process:
too few arguments”
${param:-default} set default if null
${#param} length of param
${param%word} remove smallest suffix pattern
${param%%word} remove largest suffix pattern
${param#word} remove smallest prefix pattern
${param##word} remove largest prefix pattern
www.vibranttechnologies.co.in
58
Parameter Expansion
#!/bin/sh
unset foo
echo ${foo:-bar}
foo=fud
echo ${foo:-bar}
foo=/usr/bin/X11/startx
echo ${foo#*/}
echo ${foo##*/}
bar=/usr/local/etc/local/networks
echo ${bar%local*}
echo ${bar%%local*}
Exit 0
Output
bar
fud
usr/bin/X11/startx
startx
/usr/local/etc
/usr
www.vibranttechnologies.co.in
59
Here Documents
 A here document is a special-purpose code block, starts
with <<
#!/bin.sh
cat <<!FUNKY!
hello
this is a here
document
!FUNCKY!
exit 0
#!/bin.sh
ed a_text_file <<HERE
3
d
.,$s/is/was/
w
q
HERE
exit 0
Output
That is line 1
That is line 2
That was line 4
a_text_file
That is line 1
That is line 2
That is line 3
That is line 4
www.vibranttechnologies.co.in
60
Debug
 sh –n<script> set -o noexec check syntax
set –n
 sh –v<script> set -o verbose echo command before
set –v
 sh –x<script> set –o trace echo command after
set –x
set –o nounset gives error if undefined
set –x
set –o xtrace
set +o xtrace
trap ‘echo Exiting: critical variable =$critical_variable’
EXIT
www.vibranttechnologies.co.in
61
Thank You…
www.vibranttechnologies.co.in

More Related Content

What's hot

Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
iCreateWorld
 
003 scripting
003 scripting003 scripting
003 scripting
Sherif Mousa
 
Unix shell scripting
Unix shell scriptingUnix shell scripting
Unix shell scripting
Pavan Devarakonda
 
Findbin libs
Findbin libsFindbin libs
Findbin libs
Workhorse Computing
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10
acme
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
Manav Prasad
 
Unix lab manual
Unix lab manualUnix lab manual
Unix lab manual
Chaitanya Kn
 
Yapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed PerlYapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed Perl
Hideaki Ohno
 
Ruby 2.0
Ruby 2.0Ruby 2.0
Ruby 2.0
Uģis Ozols
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
Tiago Peczenyj
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
Corrado Santoro
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!
Workhorse Computing
 
Linux shell script-1
Linux shell script-1Linux shell script-1
Linux shell script-1
兎 伊藤
 
BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command Interpolation
Workhorse Computing
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
Andrew Shitov
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
lichtkind
 
I, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 OverlordsI, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 Overlords
heumann
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programming
kayalkarnan
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
Marwan Osman
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
Abhay Sapru
 

What's hot (20)

Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
 
003 scripting
003 scripting003 scripting
003 scripting
 
Unix shell scripting
Unix shell scriptingUnix shell scripting
Unix shell scripting
 
Findbin libs
Findbin libsFindbin libs
Findbin libs
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Unix lab manual
Unix lab manualUnix lab manual
Unix lab manual
 
Yapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed PerlYapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed Perl
 
Ruby 2.0
Ruby 2.0Ruby 2.0
Ruby 2.0
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!
 
Linux shell script-1
Linux shell script-1Linux shell script-1
Linux shell script-1
 
BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command Interpolation
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
I, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 OverlordsI, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 Overlords
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programming
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 

Viewers also liked

(How) Does VA Smalltalk fit into today's IT landscapes?
(How) Does VA Smalltalk fit into today's IT landscapes?(How) Does VA Smalltalk fit into today's IT landscapes?
(How) Does VA Smalltalk fit into today's IT landscapes?
Joachim Tuchel
 
IBM Cobol Programming
IBM Cobol ProgrammingIBM Cobol Programming
IBM Cobol ProgrammingRui Andrade
 
Pascal hilbert1 a.
Pascal hilbert1 a.Pascal hilbert1 a.
Pascal hilbert1 a.
Mark Hilbert
 
Free Trial: How to access Options Pricing?
Free Trial: How to access Options Pricing?Free Trial: How to access Options Pricing?
Free Trial: How to access Options Pricing?
Muruganantha Nadesapillai
 
Pascal spinoza
Pascal spinozaPascal spinoza
Pascal spinoza
Mark Hilbert
 
Pascal Metrics - Current Use Of Technology In Automating Patient Harm Identif...
Pascal Metrics - Current Use Of Technology In Automating Patient Harm Identif...Pascal Metrics - Current Use Of Technology In Automating Patient Harm Identif...
Pascal Metrics - Current Use Of Technology In Automating Patient Harm Identif...
William Andrews
 
Build JSON and XML using RABL gem
Build JSON and XML using RABL gemBuild JSON and XML using RABL gem
Build JSON and XML using RABL gem
Nascenia IT
 
Hb Services .net ieee project 2015 - 16
Hb Services .net ieee project 2015 - 16Hb Services .net ieee project 2015 - 16
Hb Services .net ieee project 2015 - 16
HB Educational Services
 
Introduction to Smalltalk
Introduction to SmalltalkIntroduction to Smalltalk
Introduction to Smalltalk
kim.mens
 
maXbox_Arduino_Pascal_Magazine
maXbox_Arduino_Pascal_MagazinemaXbox_Arduino_Pascal_Magazine
maXbox_Arduino_Pascal_Magazine
Max Kleiner
 
Linux Shell Scripting Craftsmanship
Linux Shell Scripting CraftsmanshipLinux Shell Scripting Craftsmanship
Linux Shell Scripting Craftsmanship
bokonen
 
Pharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source SmalltalkPharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source Smalltalk
Serge Stinckwich
 
18 baumgartner pascal
18 baumgartner pascal18 baumgartner pascal
18 baumgartner pascal
fruitbreedomics
 
15 pascal
15 pascal15 pascal
15 pascal
fruitbreedomics
 
Vistazo a SQL Server 2016
Vistazo a SQL Server 2016Vistazo a SQL Server 2016
Vistazo a SQL Server 2016
Eduardo Castro
 
PASCAL VOC 2010: semantic object segmentation and action recognition in still...
PASCAL VOC 2010: semantic object segmentation and action recognition in still...PASCAL VOC 2010: semantic object segmentation and action recognition in still...
PASCAL VOC 2010: semantic object segmentation and action recognition in still...
Media Integration and Communication Center
 
Thales Smalltalk Usage: PicUnit
Thales Smalltalk Usage: PicUnitThales Smalltalk Usage: PicUnit
Thales Smalltalk Usage: PicUnit
ESUG
 
Building Seaside Applications in VA Smalltalk
Building Seaside Applications in VA SmalltalkBuilding Seaside Applications in VA Smalltalk
Building Seaside Applications in VA Smalltalk
Joachim Tuchel
 
Google Display Network - Searchstrategies 2010 - Pascal van Laere
Google Display Network - Searchstrategies 2010 - Pascal van LaereGoogle Display Network - Searchstrategies 2010 - Pascal van Laere
Google Display Network - Searchstrategies 2010 - Pascal van Laere
Yonego | ROI Driven Internet Marketing
 
assignment riordan manufacturing process improvement final
 assignment riordan manufacturing process improvement final   assignment riordan manufacturing process improvement final
assignment riordan manufacturing process improvement final
cnathan124
 

Viewers also liked (20)

(How) Does VA Smalltalk fit into today's IT landscapes?
(How) Does VA Smalltalk fit into today's IT landscapes?(How) Does VA Smalltalk fit into today's IT landscapes?
(How) Does VA Smalltalk fit into today's IT landscapes?
 
IBM Cobol Programming
IBM Cobol ProgrammingIBM Cobol Programming
IBM Cobol Programming
 
Pascal hilbert1 a.
Pascal hilbert1 a.Pascal hilbert1 a.
Pascal hilbert1 a.
 
Free Trial: How to access Options Pricing?
Free Trial: How to access Options Pricing?Free Trial: How to access Options Pricing?
Free Trial: How to access Options Pricing?
 
Pascal spinoza
Pascal spinozaPascal spinoza
Pascal spinoza
 
Pascal Metrics - Current Use Of Technology In Automating Patient Harm Identif...
Pascal Metrics - Current Use Of Technology In Automating Patient Harm Identif...Pascal Metrics - Current Use Of Technology In Automating Patient Harm Identif...
Pascal Metrics - Current Use Of Technology In Automating Patient Harm Identif...
 
Build JSON and XML using RABL gem
Build JSON and XML using RABL gemBuild JSON and XML using RABL gem
Build JSON and XML using RABL gem
 
Hb Services .net ieee project 2015 - 16
Hb Services .net ieee project 2015 - 16Hb Services .net ieee project 2015 - 16
Hb Services .net ieee project 2015 - 16
 
Introduction to Smalltalk
Introduction to SmalltalkIntroduction to Smalltalk
Introduction to Smalltalk
 
maXbox_Arduino_Pascal_Magazine
maXbox_Arduino_Pascal_MagazinemaXbox_Arduino_Pascal_Magazine
maXbox_Arduino_Pascal_Magazine
 
Linux Shell Scripting Craftsmanship
Linux Shell Scripting CraftsmanshipLinux Shell Scripting Craftsmanship
Linux Shell Scripting Craftsmanship
 
Pharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source SmalltalkPharo, an innovative and open-source Smalltalk
Pharo, an innovative and open-source Smalltalk
 
18 baumgartner pascal
18 baumgartner pascal18 baumgartner pascal
18 baumgartner pascal
 
15 pascal
15 pascal15 pascal
15 pascal
 
Vistazo a SQL Server 2016
Vistazo a SQL Server 2016Vistazo a SQL Server 2016
Vistazo a SQL Server 2016
 
PASCAL VOC 2010: semantic object segmentation and action recognition in still...
PASCAL VOC 2010: semantic object segmentation and action recognition in still...PASCAL VOC 2010: semantic object segmentation and action recognition in still...
PASCAL VOC 2010: semantic object segmentation and action recognition in still...
 
Thales Smalltalk Usage: PicUnit
Thales Smalltalk Usage: PicUnitThales Smalltalk Usage: PicUnit
Thales Smalltalk Usage: PicUnit
 
Building Seaside Applications in VA Smalltalk
Building Seaside Applications in VA SmalltalkBuilding Seaside Applications in VA Smalltalk
Building Seaside Applications in VA Smalltalk
 
Google Display Network - Searchstrategies 2010 - Pascal van Laere
Google Display Network - Searchstrategies 2010 - Pascal van LaereGoogle Display Network - Searchstrategies 2010 - Pascal van Laere
Google Display Network - Searchstrategies 2010 - Pascal van Laere
 
assignment riordan manufacturing process improvement final
 assignment riordan manufacturing process improvement final   assignment riordan manufacturing process improvement final
assignment riordan manufacturing process improvement final
 

Similar to Best training-in-mumbai-shell scripting

Raspberry pi Part 4
Raspberry pi Part 4Raspberry pi Part 4
Raspberry pi Part 4
Techvilla
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Dr.Ravi
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
Gaurav Shinde
 
Shell programming
Shell programmingShell programming
Shell programming
Moayad Moawiah
 
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEAShell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Thuy_Dang
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
mugeshmsd5
 
Bash production guide
Bash production guideBash production guide
Bash production guide
Adrien Mahieux
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Manav Prasad
 
03 tk2123 - pemrograman shell-2
03   tk2123 - pemrograman shell-203   tk2123 - pemrograman shell-2
03 tk2123 - pemrograman shell-2
Setia Juli Irzal Ismail
 
Unix
UnixUnix
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming language
René Ribaud
 
34-shell-programming.ppt
34-shell-programming.ppt34-shell-programming.ppt
34-shell-programming.ppt
KiranMantri
 
Advanced linux chapter ix-shell script
Advanced linux chapter ix-shell scriptAdvanced linux chapter ix-shell script
Advanced linux chapter ix-shell script
Eliezer Moraes
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
Dr.Ravi
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Sudharsan S
 
Slides
SlidesSlides
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, PuppetPuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
Puppet
 
KT on Bash Script.pptx
KT on Bash Script.pptxKT on Bash Script.pptx
KT on Bash Script.pptx
gogulasivannarayana
 
Licão 09 variables and arrays v2
Licão 09 variables and arrays v2Licão 09 variables and arrays v2
Licão 09 variables and arrays v2
Acácio Oliveira
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
Prof. Wim Van Criekinge
 

Similar to Best training-in-mumbai-shell scripting (20)

Raspberry pi Part 4
Raspberry pi Part 4Raspberry pi Part 4
Raspberry pi Part 4
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Shell programming
Shell programmingShell programming
Shell programming
 
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEAShell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEA
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
 
Bash production guide
Bash production guideBash production guide
Bash production guide
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
03 tk2123 - pemrograman shell-2
03   tk2123 - pemrograman shell-203   tk2123 - pemrograman shell-2
03 tk2123 - pemrograman shell-2
 
Unix
UnixUnix
Unix
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming language
 
34-shell-programming.ppt
34-shell-programming.ppt34-shell-programming.ppt
34-shell-programming.ppt
 
Advanced linux chapter ix-shell script
Advanced linux chapter ix-shell scriptAdvanced linux chapter ix-shell script
Advanced linux chapter ix-shell script
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Slides
SlidesSlides
Slides
 
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, PuppetPuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
 
KT on Bash Script.pptx
KT on Bash Script.pptxKT on Bash Script.pptx
KT on Bash Script.pptx
 
Licão 09 variables and arrays v2
Licão 09 variables and arrays v2Licão 09 variables and arrays v2
Licão 09 variables and arrays v2
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
 

Recently uploaded

Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
saastr
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 

Recently uploaded (20)

Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 

Best training-in-mumbai-shell scripting

  • 3. 3 Outline  What is shell?  Basic  Syntax  Lists  Functions  Command Execution  Here Documents  Debug  Regular Expression  Find www.vibranttechnologies.co.in
  • 4. 4 Why Shell?  The commercial UNIX used Korn Shell  For Linux, the Bash is the default  Why Shell?  For routing jobs, such as system administration, without writing programs  However, the shell script is not efficient, therefore, can be used for prototyping the ideas  For example, % ls –al | more (better format of listing directory) % man bash | col –b | lpr (print man page of man) www.vibranttechnologies.co.in
  • 5. 5 What is Shell?  Shell is the interface between end user and the Linux system, similar to the commands in Windows  Bash is installed as in /bin/sh  Check the version % /bin/sh --version Kernel Other programs X window bash csh www.vibranttechnologies.co.in
  • 6. 6 Pipe and Redirection  Redirection (< or >) % ls –l > lsoutput.txt (save output to lsoutput.txt) % ps >> lsoutput.txt (append to lsoutput.txt) % more < killout.txt (use killout.txt as parameter to more) % kill -l 1234 > killouterr.txt 2 >&1 (redirect to the same file) % kill -l 1234 >/dev/null 2 >&1 (ignore std output)  Pipe (|)  Process are executed concurrently % ps | sort | more % ps –xo comm | sort | uniq | grep –v sh | more % cat mydata.txt | sort | uniq | > mydata.txt (generates an empty file !) www.vibranttechnologies.co.in
  • 7. 7 Shell as a Language  We can write a script containing many shell commands  Interactive Program:  grep files with POSIX string and print it % for file in * > do > if grep –l POSIX $file > then > more $file  fi  done Posix There is a file with POSIX in it  ‘*’ is wildcard % more `grep –l POSIX *` % more $(grep –l POSIX *) % more –l POSIX * | more www.vibranttechnologies.co.in
  • 8. 8 Writing a Script  Use text editor to generate the “first” file #!/bin/sh # first # this file looks for the files containing POSIX # and print it for file in * do if grep –q POSIX $file then echo $file fi done exit 0 % /bin/sh first % chmod +x first %./first (make sure . is include in PATH parameter) exit code, 0 means successful www.vibranttechnologies.co.in
  • 9. 9 Syntax  Variables  Conditions  Control  Lists  Functions  Shell Commands  Result  Document www.vibranttechnologies.co.in
  • 10. 10 Variables  Variables needed to be declared, note it is case-sensitive (e.g. foo, FOO, Foo)  Add ‘$’ for storing values % salutation=Hello % echo $salutation Hello % salutation=7+5 % echo $salutation 7+5 % salutation=“yes dear” % echo $salutation yes dear % read salutation Hola! % echo $salutation Hola! www.vibranttechnologies.co.in
  • 11. 11 Quoting  Edit a “vartest.sh” file #!/bin/sh myvar=“Hi there” echo $myvar echo “$myvar” echo `$myvar` echo $myvar echo Enter some text read myvar echo ‘$myvar’ now equals $myvar exit 0 Output Hi there Hi there $myvar $myvar Enter some text Hello world $myvar now equals Hello world www.vibranttechnologies.co.in
  • 12. 12 Environment Variables  $HOME home directory  $PATH path  $PS1 第一層提示符號 (normally %)  $PS2 第二層提示符號 (normally >)  $$ process id of the script  $# number of input parameters  $0 name of the script file  $IFS separation character (white space)  Use ‘env’ to check the valuewww.vibranttechnologies.co.in
  • 13. 13 Parameter % IFS = ` ` % set foo bar bam % echo “$@” foo bar bam % echo “$*” foo bar bam % unset IFS % echo “$*” foo bar bam doesn’t matter IFS www.vibranttechnologies.co.in
  • 14. 14 Condition  test or ‘ [ ‘ if test –f fred.c then ... fi If [ -f fred.c ] then ... fi if [ -f fred.c ];then ... fi expression1 –eq expression2 expression1 –ne expression2 expression1 –gt expression2 expression1 –ge expression2 expression1 -lt expression2 expression1 –le expression2 !expression -d file if directory -e file if exist -f file if file -g file if set-group-id -r file if readable -s file if size >0 -u file if set-user-id -w file if writable -x file if executableString1 = string2 String1 != string 2 -n string (if not empty string) -z string (if empty string) need space ! www.vibranttechnologies.co.in
  • 15. 15 Control Structure Syntax if condition then statement else statement fi #!/bin/sh echo “Is it morning? Please answer yes or no” read timeofday if [ $timeofday = “yes” ]; then echo “Good morning” else echo “Good afternoon” fi exit 0 Is it morning? Please answer yes or no yes Good morning www.vibranttechnologies.co.in
  • 16. 16 Condition Structure #!/bin/sh echo “Is it morning? Please answer yes or no” read timeofday if [ $timeofday = “yes” ]; then echo “Good morning” elif [ $timeofday = “no” ]; then echo “Good afternoon” else echo “Sorry, $timeofday not recongnized. Enter yes or no” exit 1 fi exit 0 www.vibranttechnologies.co.in
  • 17. 17 Condition Structure #!/bin/sh echo “Is it morning? Please answer yes or no” read timeofday if [ “$timeofday” = “yes” ]; then echo “Good morning” elif [ $timeofday = “no” ]; then echo “Good afternoon” else echo “Sorry, $timeofday not recongnized. Enter yes or no” exit 1 fi exit 0 If input “enter” still returns Good morning www.vibranttechnologies.co.in
  • 18. 18 Loop Structure Syntax for variable do statement done #!/bin/sh for foo in bar fud 43 do echo $foo done exit 0 bar fud 43 How to output as bar fud 43? Try change for foo in “bar fud 43” This is to have space in variable www.vibranttechnologies.co.in
  • 19. 19 Loop Structure  Use wildcard ‘*’ #!/bin/sh for file in $(ls f*.sh); do lpr $file done exit 0 Print all f*.sh files www.vibranttechnologies.co.in
  • 20. 20 Loop Structure Syntax while condition do statement done #!/bin/sh for foo in 1 2 3 4 5 6 7 8 9 10 do echo “here we go again” done exit 0 #!/bin/sh foo = 1 while [ “$foo” –le 10 ] do echo “here we go again” foo = $foo(($foo+1)) done exit 0 Syntax until condition do statement done Note: condition is Reverse to while How to re-write previous sample? www.vibranttechnologies.co.in
  • 21. 21 Case Statement Syntax case variable in pattern [ | pattern ] …) statement;; pattern [ | pattern ] …) statement;; … esac #!/bin/sh echo “Is it morning? Please answer yes or no” read timeofday case “$timeofday” in yes) echo “Good Morning”;; y) echo “Good Morning”;; no) echo “Good Afternoon”;; n) echo “Good Afternoon”;; * ) echo “Sorry, answer not recongnized”;; esac exit 0 www.vibranttechnologies.co.in
  • 22. 22 Case Statement  A much “cleaner” version #!/bin/sh echo “Is it morning? Please answer yes or no” read timeofday case “$timeofday” in yes | y | Yes | YES ) echo “Good Morning”;; n* | N* ) echo “Good Afternoon”;; * ) echo “Sorry, answer not recongnized”;; esac exit 0 But this has a problem, if we enter ‘never’ which obeys n* case and prints “Good Afternoon” www.vibranttechnologies.co.in
  • 23. 23 Case Statement #!/bin/sh echo “Is it morning? Please answer yes or no” read timeofday case “$timeofday” in yes | y | Yes | YES ) echo “Good Morning” echo “Up bright and early this morning” ;; [nN]*) echo “Good Afternoon”;; *) echo “Sorry, answer not recongnized” echo “Please answer yes of no” exit 1 ;; esac exit 0 www.vibranttechnologies.co.in
  • 24. 24 List  AND (&&) statement1 && statement2 && statement3 … #!/bin/sh touch file_one rm –f file_two if [ -f file_one ] && echo “Hello” && [-f file_two] && echo “ there” then echo “in if” else echo “in else” fi exit 0 Output Hello in else Check if file exist if not then create one Remove a file www.vibranttechnologies.co.in
  • 25. 25 List  OR (||) statement1 || statement2 || statement3 … #!/bin/sh rm –f file_one if [ -f file_one ] || echo “Hello” || echo “ there” then echo “in if” else echo “in else” fi exit 0 Output Hello in else www.vibranttechnologies.co.in
  • 26. 26 Statement Block  Use multiple statements in the same place get_comfirm && { grep –v “$cdcatnum” $stracks_file > $temp_file cat $temp_file > $tracks_file echo add_record_tracks } www.vibranttechnologies.co.in
  • 27. 27 Function  You can define functions for “structured” scripts function_name() { statements } #!/bin/sh foo() { echo “Function foo is executing” } echo “script starting” foo echo “script ended” exit 0 Output script starting Function foo is executing Script ended You need to define a function before using it The parameters $*,$@,$#,$1,$2 are replaced by local value if function is called and return to previous after function is finished www.vibranttechnologies.co.in
  • 28. 28 Function #!/bin/sh sample_text=“global variable” foo() { local sample_text=“local variable” echo “Function foo is executing” echo $sample_text } echo “script starting” echo $sample_text foo echo “script ended” echo $sample_text exit 0 define local variable Output? Check the scope of the variables www.vibranttechnologies.co.in
  • 29. 29 Function  Use return to pass a result #!/bin/sh yes_or_no() { echo “Is your name $* ?” while true do echo –n “Enter yes or no:” read x case “$x” in y | yes ) return 0;; n | no ) return 1;; * ) echo “Answer yes or no” esac done } echo “Original parameters are $*” if yes_or_no “$1” then echo “Hi $1, nice name” else echo “Never mind” fi exit 0 Output ./my_name John Chuang Original parameters are John Chuang Is your name John? Enter yes or no: yes Hi John, nice name. www.vibranttechnologies.co.in
  • 30. 30 Command  External: use interactively  Internal:  only in script  break skip loop #!/bin/sh rm –rf fred* echo > fred1 echo > fred2 mkdir fred3 echo > fred4 for file in fred* do if [ -d “$file” ] ; then break; fi done echo first directory starting fred was $file rm –rf fred* exit 0 www.vibranttechnologies.co.in
  • 31. 31 Command  : treats it as true #!/bin/sh rm –f fred if [ -f fred ]; then : else echo file fred did not exist fi exit 0 www.vibranttechnologies.co.in
  • 32. 32 Command  continue continues next iteration #!/bin/sh rm –rf fred* echo > fred1 echo > fred2 mkdir fred3 echo > fred4 for file in fred* do if [ -d “$file” ]; then echo “skipping directory $file” continue fi echo file is $file done rm –rf fred* exit 0 www.vibranttechnologies.co.in
  • 33. 33 Command  . ./shell_script execute shell_script classic_set #!/bin/sh verion=classic PATH=/usr/local/old_bin:/usr/bin:/bin:. PS1=“classic> ” latest_set #!/bin/sh verion=latest PATH=/usr/local/new_bin:/usr/bin:/bin:. PS1=“latest version> ” % . ./classic_set classic> echo $version classic Classic> . latest_set latest latest version> www.vibranttechnologies.co.in
  • 34. 34 Command  echo print string  -n do not output the trailing newline  -e enable interpretation of backslash escapes  0NNN the character whose ACSII code is NNN  backslash  a alert  b backspace  c suppress trailing newline  f form feed  n newline  r carriage return  t horizontal tab  v vertical tab Try these % echo –n “string to n output” % echo –e “string to n output” www.vibranttechnologies.co.in
  • 35. 35 Command  eval evaluate the value of a parameter similar to an extra ‘$’ % foo=10 % x=foo % y=‘$’$x % echo $y Output is $foo % foo=10 % x=foo % eval y=‘$’$x % echo $y Output is 10 www.vibranttechnologies.co.in
  • 36. 36 Command  exit n ending the script  0 means success  1 to 255 means specific error code  126 means not executable file  127 means no such command  128 or >128 signal #!/bin/sh if [ -f .profile ]; then exit 0 fi exit 1 Or % [ -f .profile ] && exit 0 || exit 1 www.vibranttechnologies.co.in
  • 37. 37 Command  export gives a value to a parameter This is ‘export2’ #!/bin/sh echo “$foo” echo “$bar” This is ‘export1’ #!/bin/sh foo=“The first meta-syntactic variable” export bar=“The second meta-syntactic variable” export2 Output is %export1 The second-syntactic variable % www.vibranttechnologies.co.in
  • 38. 38 Command  expr evaluate expressions %x=`expr $x + 1` (Assign result value expr $x+1 to x) Also can be written as %x=$(expr $x + 1) Expr1 | expr2 (or) expr1 != expr2 Expr1 & expr2 (and) expr1 + expr2 Expr1 = expr2 expr1 – expr2 Expr1 > expr2 expr1 * expr2 Expr1 >= expr2 expr1 / expr2 Expr1 < expr2 expr1 % expr2 (module) Expr1 <= expr2 www.vibranttechnologies.co.in
  • 39. 39 Command  printf format and print data  Escape sequence  backslash  a beep sound  b backspace  f form feed  n newline  r carriage return  t tab  v vertical tab  Conversion specifier  %d decimal  %c character  %s string  %% print % % printf “%sn” hello Hello % printf “%s %dt%s” “Hi There” 15 people Hi There 15 people www.vibranttechnologies.co.in
  • 40. 40 Command  return return a value  set set parameter variable #!/bin/sh echo the date is $(date) set $(date) echo The month is $2 exit 0 www.vibranttechnologies.co.in
  • 41. 41 Command  Shift shift parameter once, $2 to $1, $3 to $2, and so on #!/bin/sh while [ “$1” != “” ]; do echo “$1” shift done exit 0 www.vibranttechnologies.co.in
  • 42. 42 Command  trap action after receiving signal trap command signal  signal explain HUP (1) hung up INT (2) interrupt (Crtl + C) QUIT (3) Quit (Crtl + ) ABRT (6) Abort ALRM (14) Alarm TERM (15) Terminate www.vibranttechnologies.co.in
  • 43. 43 Command #!/bin/sh trap ‘rm –f /tmp/my_tmp_file_$$’ INT echo creating file /tmp/my_tmp_file_$$ date > /tmp/my_tmp_file_$$ echo “press interrupt (CTRL-C) to interrupt …” while [ -f /tmp/my_tmp_file_$$ ]; do echo File exists sleep 1 done echo The file no longer exists trap INT echo creating file /tmp/my_tmp_file_$$ date > /tmp/my_tmp_file_$$ echo “press interrupt (CTRL-C) to interrupt …” while [ -f /tmp/my_tmp_file_$$ ]; do echo File exists sleep 1 done echo we never get there exit 0 www.vibranttechnologies.co.in
  • 44. 44 Command creating file /tmp/my_file_141 press interrupt (CTRL-C) to interrupt … File exists File exists File exists File exists The file no longer exists Creating file /tmp/my_file_141 Press interrupt (CTRL-C) to interrupt … File exists File exists File exists File exists www.vibranttechnologies.co.in
  • 45. 45 Command Unset remove parameter or function #!/bin/sh foo=“Hello World” echo $foo unset $foo echo $foo www.vibranttechnologies.co.in
  • 46. 46 Pattern Matching  find search for files in a directory hierarchy find [path] [options] [tests] [actions] options -depth find content in the directory -follow follow symbolic links -maxdepths N fond N levels directories -mount do not find other directories tests -atime N accessed N days ago -mtime N modified N days ago -new otherfile name of a file -type X file type X -user username belong to username www.vibranttechnologies.co.in
  • 47. 47 Pattern Matching operator ! -not test reverse -a -and test and -o -or test or action -exec command execute command -ok command confirm and exectute command -print print -ls ls –dils Find files newer than while2 then print % find . –newer while2 -print www.vibranttechnologies.co.in
  • 48. 48 Pattern Matching Find files newer than while2 then print only files % find . –newer while2 –type f –print Find files either newer than while2, start with ‘_’ % find . ( -name “_*” –or –newer while2 ) –type f –print Find files newer than while2 then list files % find . –newer while2 –type f –exec ls –l {} ; www.vibranttechnologies.co.in
  • 49. 49 Pattern Matching  grep print lines matching a pattern (General Regular Expression Parser) grep [options] PATTERN [FILES] option -c print number of output context -E Interpret PATTERN as an extended regular expression -h Supress the prefixing of filenames -i ignore case -l surpress normal output -v invert the sense of matching % grep in words.txt % grep –c in words.txt words2.txt % grep –c –v in words.txt words2.txt www.vibranttechnologies.co.in
  • 50. 50 Regular Expressions  a regular expression (abbreviated as regexp or regex, with plural forms regexps, regexes, or regexen) is a string that describes or matches a set of strings, according to certain syntax rules.  Syntax  ^ Matches the start of the line  $ Matches the end of the line  . Matches any single character  [] Matches a single character that is contained within the brackets  [^] Matches a single character that is not contained within the brackets  () Defines a "marked subexpression”  {x,y}Match the last "block" at least x and not more than y times www.vibranttechnologies.co.in
  • 51. 51 Regular Expressions  Examples:  ".at" matches any three-character string like hat, cat or bat  "[hc]at" matches hat and cat  "[^b]at" matches all the matched strings from the regex ".at" except bat  "^[hc]at" matches hat and cat but only at the beginning of a line  "[hc]at$" matches hat and cat but only at the end of a line www.vibranttechnologies.co.in
  • 52. 52 Regular Expressions  POSIX class similar to meaning  [:upper:] [A-Z] uppercase letters  [:lower:] [a-z] lowercase letters  [:alpha:] [A-Za-z] upper- and lowercase letters  [:alnum:] [A-Za-z0-9] digits, upper- and lowercase letters  [:digit:] [0-9] digits  [:xdigit:] [0-9A-Fa-f] hexadecimal digits  [:punct:] [.,!?:...] punctuation  [:blank:] [ t] space and TAB characters only  [:space:] [ tnrfv]blank (whitespace) characters  [:cntrl:] control characters  [:graph:] [^ tnrfv] printed characters  [:print:] [^tnrfv] printed characters and space  Example: [[:upper:]ab] should only match the uppercase letters and lowercase 'a' and 'b'. www.vibranttechnologies.co.in
  • 53. 53 Regular Expressions  POSIX modern (extended) regular expressions  The more modern "extended" regular expressions can often be used with modern Unix utilities by including the command line flag "-E".  + Match one or more times  ? Match at most once  * Match zero or more  {n} Match n times  {n,} Match n or more times  {n,m} Match n to m times www.vibranttechnologies.co.in
  • 54. 54 Regular Expressions  Search for lines ending with “e” % grep e$ words2.txt  Search for “a” % grep a[[:blank:]] word2.txt  Search for words starting with “Th.” % grep Th.[[:blank:]] words2.txt  Search for lines with 10 lower case characters % grep –E [a-z]{10} words2.txt www.vibranttechnologies.co.in
  • 55. 55 Command  $(command) to execute command in a script  Old format used “`” but it can be confused with “’” #!/bin/sh echo The current directory is $PWD echo the current users are $(who) www.vibranttechnologies.co.in
  • 56. 56 Arithmetic Expansion  Use $((…)) instead of expr to evaluate arithmetic equation #!/bin/sh x=0 while [ “$x” –ne 10]; do echo $x x=$(($x+1)) done exit 0 www.vibranttechnologies.co.in
  • 57. 57 Parameter Expansion  Parameter Assignment foo=fred echo $foo #!/bin/sh for i in 1 2 do my_secret_process ${i}_tmp done #!/bin/sh for i in 1 2 do my_secret_process $i_tmp done Gives result “mu_secret_process: too few arguments” ${param:-default} set default if null ${#param} length of param ${param%word} remove smallest suffix pattern ${param%%word} remove largest suffix pattern ${param#word} remove smallest prefix pattern ${param##word} remove largest prefix pattern www.vibranttechnologies.co.in
  • 58. 58 Parameter Expansion #!/bin/sh unset foo echo ${foo:-bar} foo=fud echo ${foo:-bar} foo=/usr/bin/X11/startx echo ${foo#*/} echo ${foo##*/} bar=/usr/local/etc/local/networks echo ${bar%local*} echo ${bar%%local*} Exit 0 Output bar fud usr/bin/X11/startx startx /usr/local/etc /usr www.vibranttechnologies.co.in
  • 59. 59 Here Documents  A here document is a special-purpose code block, starts with << #!/bin.sh cat <<!FUNKY! hello this is a here document !FUNCKY! exit 0 #!/bin.sh ed a_text_file <<HERE 3 d .,$s/is/was/ w q HERE exit 0 Output That is line 1 That is line 2 That was line 4 a_text_file That is line 1 That is line 2 That is line 3 That is line 4 www.vibranttechnologies.co.in
  • 60. 60 Debug  sh –n<script> set -o noexec check syntax set –n  sh –v<script> set -o verbose echo command before set –v  sh –x<script> set –o trace echo command after set –x set –o nounset gives error if undefined set –x set –o xtrace set +o xtrace trap ‘echo Exiting: critical variable =$critical_variable’ EXIT www.vibranttechnologies.co.in