Thursday, 11 December 2014

Write a Shell Script to perform various operations based upon the choice on the files

Write a Shell Script which takes two files as input and performs the following action based upon the choice entered by the user:
1- Link the two files
2- Copy a file contents
3- Renaming a file
4- Removing a file

Solution: 
echo Enter the two Files
read file1 file2
echo Press 1 for Linking the files
echo Press 2 for Copying a file contents
echo Press 3 for Renaming a file
echo Press 4 for Removing a file
echo Enter Your Choice
read choice
case $choice in
1)ln $file1 $file2;;
2)cp $file1 $file2;;
3)mv $file1 $file2;;
4)rm $file1 $file2;;
*)echo Invalid Choice;;
esac

Execution:
                                                                               

No comments:

Post a Comment