Program for Palindrome

cat filename|while read LINE
do
REVERSE=`echo "${LINE}"|rev`
if [ "${LINE}" = "${REVERSE}" ]
then
echo "Palidrome: ${LINE}"
fi
done

Program for print star

echo "Stars"

for (( i=1; i<=5; i++ ))
do
for (( j=1; j<=i; j++ ))
do
echo -n " *"
done
echo ""
done

for (( i=5; i>=1; i-- ))
do
for (( j=1; j<=i; j++ ))
do
echo -n " *"
done
echo ""
done

Program for for-loop

echo "Can you see the following:"

for (( i=1; i<=5; i++ ))
do
for (( j=1; j<=i; j++ ))
do
echo -n "$i"
done
echo ""
done


echo "Can you see the following:"

for (( i=1; i<=5; i++ ))
do
for (( j=1; j<=i; j++ ))
do
echo -n "$j"
done
echo ""
done

Program for Digit

if [ $# -ne 1 ]
then
echo "Usage: $0 number"
echo " I will find sum of all digit for given number"
echo " For eg. $0 123, I will print 6 as sum of all digit (1+2+3)"
exit 1
fi

n=$1
sum=0
sd=0
while [ $n -gt 0 ]
do
sd=`expr $n % 10`
sum=`expr $sum + $sd`
n=`expr $n / 10`
done
echo "Sum of digit for numner is $sum"

Program for reverse order

if [ $# -ne 1 ]
then
echo "Usage: $0 number"
echo " I will find reverse of given number"
echo " For eg. $0 123, I will print 321"
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"

File System in Linux

The Linux operating system provides a file system to organized the data on Linux based computer. The file system has a hierarchical tree like structure to store file in a directory. File containing data of similar nature are place under one directory. All the Linux files are stored in one main directory called root. The administrator of the Linux operating system stored all the home directory of the end user in the slash(/) home directory.

Copy & Paste Command

yy/Y :- Select the current line that is to be copied.

nyy/NY :- Select a line including the current line.

P :- Places the selected text after the current cursor position.

p :- Places the selected text before the current cursor position.