set this is the forty fifth tutorial
echo $1 // this
echo $2 // is
How does unix decide which word has to be assigned to which positional parameter?
By looking for the internal field seperator(IFS) in the setence.
default value of IFS is <space><tab><newline>
ifs.sh:
line = "Shell Scripting is fun."
set $line
echo $1
echo $2
echo $3
echo $4
sh ifs.sh
Shell
Scripting
is
fun.
ifs.sh:
line = "Shell Scripting is fun."
IFS=:
set $line
echo $1
echo $2
echo $3
echo $4
sh ifs.sh
Shell Scripting is fun.
// blank line
// blank line
// blank line
ifs.sh:
line ="Shell:Scripting:is:fun."
IFS=:
set $line
echo $1
echo $2
echo $3
echo $4
sh ifs.sh
Shell
Scripting
is
fun.