#Script showing username, date, user_id and current directory
echo "Hello, $LOGNAME"
echo "Current date is `date`"
echo "User is `who i am`"
echo "Current directory `pwd`"
#Script giving execution permission and executing
chmod 755 file.sh
./file.sh
#To find reverse of a number
# sh script.sh 3487
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Usage: $0 number"
echo " I will find reverse of given number"
echo " For eg. $0 0123, I will print 3210"
exit 1
fi
n=$1
rev=0
sd=0
while [ $n -gt 0 ]
do
sd=`expr $n % 10`
rev=`expr $rev \* 10 + $sd`
n=`expr $n / 10`
done
echo "Reverse number is $rev"
#Pipe the calculated value to bc command
echo 7.56 + 2.453 | bc
# Show value of pi up to 15 digits (for it pi package must be installed)
pi 15
echo "Hello, $LOGNAME"
echo "Current date is `date`"
echo "User is `who i am`"
echo "Current directory `pwd`"
#Script giving execution permission and executing
chmod 755 file.sh
./file.sh
#To find reverse of a number
# sh script.sh 3487
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Usage: $0 number"
echo " I will find reverse of given number"
echo " For eg. $0 0123, I will print 3210"
exit 1
fi
n=$1
rev=0
sd=0
while [ $n -gt 0 ]
do
sd=`expr $n % 10`
rev=`expr $rev \* 10 + $sd`
n=`expr $n / 10`
done
echo "Reverse number is $rev"
#Pipe the calculated value to bc command
echo 7.56 + 2.453 | bc
# Show value of pi up to 15 digits (for it pi package must be installed)
pi 15
No comments:
Post a Comment