Friday, July 26, 2013

INTERNAL AND EXTERNAL COMMANDS



The Shell has a number of built-in commands. These are called internal commands. Ex: cd, echo etc. These do not generate a process and are executed directly by the Shell.

The commands that are outside the Shell architecture are known as external commands. Ex: cat, ls etc. The Shell creates a process for each of these commands.

type command will let us know whether a command is internal or external.

echo and printf :
These commands are used to print messages on the screen.
$ echo computer
$ printf “computer \n”

Shell Variables And Their Assignment

$ var=value
$ x=123
$ y=”data”
if x is a variable, $x indicates its value.

We can input the values into the variables using read.

$ read x y

using declare command, we can set controls over the input.

$ declare –r a ( read only)
$ declare –i b ( integer only)

let command allows to perform various arithmetic expressions,

$ x=1
$ y=2
$ let z =x+y  ( +, -, *, /, %)
printf “$z\n”

expr command is used perform string related operations

$ a=”data”
$ expr length $a ( finds the length of the variabl)

$ expr substr $a  1 2 ( finds the substring from 1 to 2 position nos. )

$ expr index $a “t”  (finds the position no. of the character in the string)

alias is used to create own command in our environment.

$ alias l=’ls –l’
$ l (will give the result of ls –l)

No comments:

Post a Comment