Sh Scripting Programming Assignment Help

Sh Scripting Language

Sh is a scripting language written for the shell or the command line interpreter of an operating system. Every bourne shell script should begin with the line #!bin/sh this shows that the content of the file are executed as a shell script. Sh scripting language is the first scripting language but now there are many scripting languages : csh, ksh, bash and others. In Sh scripting language the comments are begin wit # (pound) sign and continue throughout the line. The file should be save in the current directory. Scripting languages support the all features of the high-level programming like condition statements, iteration statements.

Sh Build-in Commands

cd [dir]
Sets the current directory to dir. If dir is not specified, sets the current directory to the home directory

pwd
Prints the current director


Sh Scripting Programming Assignment Help By Online Tutoring and Guide Sessions at AssignmentHelp.Net


echo args
Prints args to standard output

eval args
Evaluates args as a sh expression. This allows you to construct a string on the fly (e.g., using a variable that holds the name of a variable that you want to set) and execute it

exec command
Runs the specified command, and replaces the current shell with it. That is, nothing after the exec statement will be executed, unless the exec itself fails

exit [n]
Exit the current shell with exit code n. This defaults to zero

Sh Code Example

{`
#!/bin/sh

myname=whoami

if [ $myname = root ]; then

echo "Welcome to FooSoft 3.0"

else

echo "You must be root to run this script"

exit 1

fi
`}