SHELL RECORD Full
SHELL RECORD Full
SHELL RECORD Full
no:01
AIM:
To perform a shell script to implement the file commands of rm, cp, cat, mv, cmp, we, split,
differ.
ALGORITHM:
PROGRAM:
array1.sh~ dat.sh dec.sh~ file2.txt mat.sh nav2.txt new file rec sum.sh~ test4.sh
test5.sh~ xaa
array1.sh~ dat.sh dec.sh~ file2.txt mat.sh nav2.txt new file rec sum.sh~ test4.sh
test5.sh~ xab xae xah
[student@localhost gopi]$
CAT COMMAND
[student@localhost gopi1]$ cat>makenew.txt
sona college of arts and science
^Z
[4]+ Stopped cat > makenew.txt
RESULT:
Thus the shell script commands has been successfully executed and output has been displayed.
EX:02
SYSTEM CONFIGURATION
DATE:
AIM:
To perform a shell script to print the following system configuration: a) currently logged user
and his log name b) current shell , home directory , Operating System type , current path setting ,
current working directory c) show currently logged number of users, show all available shells d)
show CPU information like processor type , speed e) show memory information
ALGORITHM:
STEP 1: Start the terminal
STEP 2: Make directory
STEP 3: Call the directory
STEP 4: Create the file with .sh extension
STEP 5: Type the program in the shell file that has been created
STEP 6 : Run the file and print the output
STEP 7 : Stop the process`
PROGRAM:
echo "enter the string"
echo "a. logged user"
echo "b.cpu information"
echo "c.block device information"
echo "d. show memory information"
echo "e. sysyem name"
echo "f. current shell"
echo "g. current date and time"
read str
case "$str" in
"a") echo "username"
who
who am i ;;
"b") echo "cpu information"
lscpu;;
"c") echo "block device information"
lsblk;;
"d") echo "show memoru information"
free -m;;
"e") echo "system name"
uname;;
"f") echo "current shell"
ostype;;
"g") echo "current date and time"
date;;
OUTPUT:
esac
RESULT:
The program was successfully executed.
EX:03
PIPES, REDIRECTION AND TEE COMMANDS
DATE:
AIM:
To perform a shell script to implement the following: pipes, redirection and tee commands.
ALGORITHM:
STEP 1: Start the terminal
STEP 2: Make directory
STEP 3: Call the directory
STEP 4: Create the file with .sh extension
STEP 5: Type the program in the shell file that has been created
STEP 6 : Run the file and print the output
STEP 7 : Stop the process`
Date:
DISPLAYING CURRENT DATE, USER NAME, FILE LISTING, DIRECTORIES.
AIM:
To perform a shell script to displaying current date, user name, file listing, directories.
ALGORITHM:
STEP1: Start the terminals.
STEP2: Make the directory for ex2 mkdir ex2.
PROGRAM:
echo "enter the string"
echo "a. today date"
echo "b. username"
echo "c. calender"
echo "d. list"
read str
case "$str" in
"a") echo "today date"
date;;
"b") echo "username"
who;;
"c") echo "calender"
cal;;
"d") echo "list of files"
ls;;
esac
OUTPUT:
RESULT:
Thus the shell script program has been successfully executed and output has been
displayed.
EX:05
CALENDER
DATE:
AIM:
To perform a shell script to modify "cal" command to display calendars of the specified range
of months.
ALGORITHM:
STEP 1: Start the terminal
STEP 2: Make directory
STEP 3: Call the directory
STEP 4: Create the file with .sh extension
STEP 5: Type the program in the shell file that has been created
STEP 6 : Run the file and print the output
STEP 7 : Stop the process`
PPROGRAM:
echo "enter the string"
echo "a. calender"
read str
case "$str" in
"a") echo "calender"
cal;;
esac
OUTPUT:
RESULT:
The program was successfully executed.
EX:06
SUM OF INDIVIDUAL DIGITS
DATE:
AIM:
To find the sum of the individual digits of a given number.
ALGORITHM:
STEP 1: Start the terminal
STEP 2: Make directory
STEP 3: Call the directory
STEP 4: Create the file with .sh extension
STEP 5: Type the program in the shell file that has been created
STEP 6 : Run the file and print the output
STEP 7 : Stop the process`
PROGRAM:
echo "enter a number "
read n
sd=0
sum=0
while [ $n -gt 0 ]
do
sd=$(($n%10))
n=$(($n/10))
sum=$(($sum+$sd))
done
echo " sum is $sum "
OUTPUT:
RESULT:
The program was successfully executed.
EX:07
GREATEST NUMBER
DATE:
AIM:
To find the greatest among the given set of numbers using line arguments
ALGORITHM:
STEP 1: Start the terminal
STEP 2: Make directory
STEP 3: Call the directory
STEP 4: Create the file with .sh extension
STEP 5: Type the program in the shell file that has been created
STEP 6 : Run the file and print the output
STEP 7 : Stop the process
PROGRAM:
RESULT:
The program was successfully executed.
EX:08
PALINDROME
DATE:
AIM:
To check whether a given number and character is a palindrome or not.
ALGORITHM:
STEP 1: Start the terminal
STEP 2: Make directory
STEP 3: Call the directory
STEP 4: Create the file with .sh extension
STEP 5: Type the program in the shell file that has been created
STEP 6 : Run the file and print the output
STEP 7 : Stop the process
PROGRAM:
A) NUMBER
echo " enter the three digit number "
read num
s=0
rev=""
temp=$num
while [ $num -gt 0 ]
do
s=$(($num%10))
num=$(($num /10))
rev=$(echo ${rev}${s})
done
if [ $temp -eq $rev ]
then
echo "number is palindrome "
else
echo "number is not a palindrome "
fi
B) STRING
echo " enter a sring "
read s
echo $s>temp
rvs="$(rev temp)"
if [ $s == $rvs ]
then
echo " it is a palindrome"
else
echo " it is not a palindrome"
fi
OUTPUT
RESULT:
The program was successfully executed
EX:09
MULTIPLICATION
DATE:
AIM:
To print the multiplication table of argument in loop.
ALGORITHM:
STEP 1: Start the terminal
STEP 2: Make directory
STEP 3: Call the directory
STEP 4: Create the file with .sh extension
STEP 5: Type the program in the shell file that has been created
STEP 6 : Run the file and print the output
STEP 7 : Stop the process
PROGRAM:
RESULT:
The program was successfully executed.
EX:10
FILE COMPARISION
DATE:
AIM:
To perform a shell script to compare two files and if found equal delete the duplicate file.
ALGORITHM:
STEP 1: Start the terminal
STEP 2: Make directory
STEP 3: Call the directory
STEP 4: Create the file with .sh extension
STEP 5: Type the program in the shell file that has been created
STEP 6 : Run the file and print the output
STEP 7 : Stop the process
PROGRAM:
RESULT:
The program was successfully executed.