ch=1
while true
do
echo "Menu"
echo "-----"
echo "1.Create a file"
echo "2.Append a file"
echo "3.Concatenation"
echo "4.Display a file"
echo "5.Copy a file"
echo "6.Move a file"
echo "7.Split a file"
echo "8.Remove a file"
echo "9.Exit"
echo "Enter your choice"
read ch
case $ch in
1)
echo "Create a file"
echo "-----------"
echo "Enter your file name"
read f1
if test -f $f1
then
echo "File already exists"
ls
else
echo "File Created"
echo "Enter your contents of the file"
cat>$f1
echo "File created with the name"$f1
ls
fi
;;
2)
echo "Append a file"
echo "-----------"
echo "Enter your first file name"
read a
echo "Enter your second file name"
read b
echo "Contents of the first file"
cat $a
echo "Contents of the second file"
cat $b
cat $a>>$b
echo "Process is Over"
echo "After append :"$b
echo "Contents of the append file"
cat $b
echo "file is not present"
;;
3)
echo "Concatenation of a file"
echo "-------------------"
echo "Enter the first file name"
read a
echo "Enter the second file name"
read b
echo "Before Concatenation"
echo "------------------"
echo "Content of first file"
cat $a
echo "Content of second file"
cat $b
echo "After Concatenation"
echo "-----------------"
cat $a $b
;;
4)
echo "Display a file"
echo "-----------"
echo "Enter the file name"
read f
if test -f $f
then
cat $f
else
echo "File not exists"
fi
;;
5)
echo "Copy of file"
echo "----------"
echo "Enter the file name"
read f1
echo "Enter the second file name to be copied"
read f2
if test -f $f1
then
cp $f1 $f2
echo "Content of the Original file"
cat $f1
echo "Content of the Copied file"
cat $f2
else
echo "File not exists"
fi
;;
6)
echo "Move a file"
echo "---------"
echo "Enter the source file"
read f
echo "Enter the destination file"
read f1
if test -f $f
then
mv $f $f1
echo "Content of the moved file"
cat $f1
ls
else
echo "File does not exists"
fi
;;
7)
echo "Split a file"
echo "---------"
echo "Enter the file name"
read a
if test -f $a
then
split -2 $a
echo "File Splitted"
ls xa*
else
echo "File not exists"
fi
;;
8)
echo "Remove a file"
echo "------------"
echo "Enter the file name"
read b
if test -f $b
then
echo "File already exists"
echo "Contents of $b file"
cat $b
rm $b
echo "File removed"
else
echo "File not found"
fi
;;
9)
echo "Exit"
exit
;;
esac
done
------------
OUTPUT:
------------
Menu
-------
1.Create a file
2.Append a file
3.Concatenation
4.Display a file
5.Copy a file
6.Move a file
7.Split a file
8.Remove a file
9.Exit
Enter your choice
1
Create a file
---------------
Enter your file name
file1
File created
Enter the contents of the file
hai
hello
welcome to all
Enter your choice
2
Append a file
-----------------
Enter the first file name
file1
Enter the second file name
aa1
Contents of the first file
-----------------------------
hai
hello
welcome to all
Contents of the second file
---------------------------------
have a nice day
god
priya
hai
hello
welcome to all
Process is Over
After append:aa1
Contents of the append file
--------------------------------
have a nice day
god
priya
hai
hello
welcome to all
hai
hello
welcome to all
file is not present
Enter your choice
3
Concatenation of a file
---------------------------
Enter the first file name
file1
Enter the second file name
aa1
Before Concatenation
--------------------------
Content of first file
-----------------------
hai
hello
welcome to all
Content of second file
--------------------------
have a nice day
god
priya
hai
hello
welcome to all
After Concatenation
------------------------
hai
hello
welcome to all
have a nice day
god
priya
hai
hello
welcome to all
Enter your choice
4
Display a file
----------------
Enter the file name
aa1
have a nice day
god
priya
hai
hello
welcome to all
Enter your choice
5
Copy a file
-------------
Enter the file name
fil1
Enter the second file name to be copied
r1
Content of the Original file
--------------------------------
hai
hello
welcome to all
Content of the Copied file
-------------------------------
hai
hello
welcome to all
Enter your choice
6
Move a File
--------------
Enter the source file
fil1
Enter the destination file
r1
Content of the moved file
-------------------------------
hai
hello
welcome to all
1 d2 friends navani rithika sasa srp1
a dad fruits p3 rk3 sasaa srp2
a2 dddd fsdg p4 rk4 sasas sss
Enter your choice
7
Split a file
------------
Enter the file name
r1
File Splitted
--------------
xaa xab xac xad
Enter your choice
8
Remove a file
-----------------
Enter the file name
r1
file already exists
Contents of r1 file
hai
hello
welcome to all
File Removed
Enter your choice
9
Exit
while true
do
echo "Menu"
echo "-----"
echo "1.Create a file"
echo "2.Append a file"
echo "3.Concatenation"
echo "4.Display a file"
echo "5.Copy a file"
echo "6.Move a file"
echo "7.Split a file"
echo "8.Remove a file"
echo "9.Exit"
echo "Enter your choice"
read ch
case $ch in
1)
echo "Create a file"
echo "-----------"
echo "Enter your file name"
read f1
if test -f $f1
then
echo "File already exists"
ls
else
echo "File Created"
echo "Enter your contents of the file"
cat>$f1
echo "File created with the name"$f1
ls
fi
;;
2)
echo "Append a file"
echo "-----------"
echo "Enter your first file name"
read a
echo "Enter your second file name"
read b
echo "Contents of the first file"
cat $a
echo "Contents of the second file"
cat $b
cat $a>>$b
echo "Process is Over"
echo "After append :"$b
echo "Contents of the append file"
cat $b
echo "file is not present"
;;
3)
echo "Concatenation of a file"
echo "-------------------"
echo "Enter the first file name"
read a
echo "Enter the second file name"
read b
echo "Before Concatenation"
echo "------------------"
echo "Content of first file"
cat $a
echo "Content of second file"
cat $b
echo "After Concatenation"
echo "-----------------"
cat $a $b
;;
4)
echo "Display a file"
echo "-----------"
echo "Enter the file name"
read f
if test -f $f
then
cat $f
else
echo "File not exists"
fi
;;
5)
echo "Copy of file"
echo "----------"
echo "Enter the file name"
read f1
echo "Enter the second file name to be copied"
read f2
if test -f $f1
then
cp $f1 $f2
echo "Content of the Original file"
cat $f1
echo "Content of the Copied file"
cat $f2
else
echo "File not exists"
fi
;;
6)
echo "Move a file"
echo "---------"
echo "Enter the source file"
read f
echo "Enter the destination file"
read f1
if test -f $f
then
mv $f $f1
echo "Content of the moved file"
cat $f1
ls
else
echo "File does not exists"
fi
;;
7)
echo "Split a file"
echo "---------"
echo "Enter the file name"
read a
if test -f $a
then
split -2 $a
echo "File Splitted"
ls xa*
else
echo "File not exists"
fi
;;
8)
echo "Remove a file"
echo "------------"
echo "Enter the file name"
read b
if test -f $b
then
echo "File already exists"
echo "Contents of $b file"
cat $b
rm $b
echo "File removed"
else
echo "File not found"
fi
;;
9)
echo "Exit"
exit
;;
esac
done
------------
OUTPUT:
------------
Menu
-------
1.Create a file
2.Append a file
3.Concatenation
4.Display a file
5.Copy a file
6.Move a file
7.Split a file
8.Remove a file
9.Exit
Enter your choice
1
Create a file
---------------
Enter your file name
file1
File created
Enter the contents of the file
hai
hello
welcome to all
Enter your choice
2
Append a file
-----------------
Enter the first file name
file1
Enter the second file name
aa1
Contents of the first file
-----------------------------
hai
hello
welcome to all
Contents of the second file
---------------------------------
have a nice day
god
priya
hai
hello
welcome to all
Process is Over
After append:aa1
Contents of the append file
--------------------------------
have a nice day
god
priya
hai
hello
welcome to all
hai
hello
welcome to all
file is not present
Enter your choice
3
Concatenation of a file
---------------------------
Enter the first file name
file1
Enter the second file name
aa1
Before Concatenation
--------------------------
Content of first file
-----------------------
hai
hello
welcome to all
Content of second file
--------------------------
have a nice day
god
priya
hai
hello
welcome to all
After Concatenation
------------------------
hai
hello
welcome to all
have a nice day
god
priya
hai
hello
welcome to all
Enter your choice
4
Display a file
----------------
Enter the file name
aa1
have a nice day
god
priya
hai
hello
welcome to all
Enter your choice
5
Copy a file
-------------
Enter the file name
fil1
Enter the second file name to be copied
r1
Content of the Original file
--------------------------------
hai
hello
welcome to all
Content of the Copied file
-------------------------------
hai
hello
welcome to all
Enter your choice
6
Move a File
--------------
Enter the source file
fil1
Enter the destination file
r1
Content of the moved file
-------------------------------
hai
hello
welcome to all
1 d2 friends navani rithika sasa srp1
a dad fruits p3 rk3 sasaa srp2
a2 dddd fsdg p4 rk4 sasas sss
Enter your choice
7
Split a file
------------
Enter the file name
r1
File Splitted
--------------
xaa xab xac xad
Enter your choice
8
Remove a file
-----------------
Enter the file name
r1
file already exists
Contents of r1 file
hai
hello
welcome to all
File Removed
Enter your choice
9
Exit
0 comments:
Post a Comment