Search This Blog

Sunday, 5 October 2014

Other Commands


To do mathematical calculation like addition, subtraction use the expr command
B=`expr $A - 1`
B=`expr $A - $C`
There should be spaces between operators (+, /, - , *) and variables.
To remove leading zeroes for an integer field
B=00014
C=`expr $B + 0`
The addition of zeroes will remove the leading zeroes and the output will be
echo $C
14
To print/display a String stored in a variable using echo
S="HELLO SIR"
echo $S
To print with some more data
S="HELLO SIR"
echo "Today's date is ${S}"
The same can be written to file using redirect
S="HELLO SIR"
echo "Today's date is ${S}" > A.txt
To print New line before printing the text
export Count=”HI”
echo -e "\n T|$Count " >> $fn.txt
To find the OS installed
uname –a  to find the OS installed
To find the host name of the UNIX box

SERVER=`hostname`

No comments:

Post a Comment