Code In Tech - The Ultimate World of Computer Technology

Monday, 4 June 2012

Shell script for interactive file handling program

SOURCE CODE:

echo "1. To copy a file"
echo "2. To rename a file"
echo "3. To remove a file"
echo "4. To compare two file"
read ch
case "$ch" in
1)
ls
echo "Enter existing file name :"
read file1

echo "Enter new file name :"
read file2
cp $file1 $file2
echo "Original file :"
cat $file1
echo "New file"
cat $file2;;
2)
ls
echo "Enter existing file name :"
read file1
echo "Enter file's new name :"
read file2
mv $file1 $file2
echo "Old file renamed which contains :"
cat $file2;;
3)
ls
echo "Enter existing file name :"
read file1
rm $file1
ls;;
4)
echo "Enter two existing file name :"
read file1
read file2
cmp $file1 $file2;;
esac

OUTPUT:

1. To copy a file
2. To rename a file
3. To remove a file
4. To compare two file

2

Enter existing file name :
user.sh
Enter file's new name :
person.sh
Old file renamed which contains :   
echo "no of users"
who | wc -l 

No comments :

Post a Comment