Tuesday, 28 July 2015

PR(03): Implementation of Create/Rename/Delete a Directory using Unix/Linux Command



while true
do
echo "1.Creation of directory";
echo "2.Deletion of Directory";
echo "3.Change Directory & Display  Node Details";
echo "4.Exit";
echo "Enter Your Choice :";
read ch;
case $ch in
1)
  echo "Enter The Directory Name to Be Created ";
  read dir;
  if [ -d $dir ]
  then
     echo "Directory Laready Existing!!!";
  else
     mkdir $dir;
     echo "Directory Created Successfully!!!";
     echo "Created Directory Can be Checked From the Following Table";
     ls -t | head -n 15
  fi
  ;;
2)
  echo "Enter The name Of the Directory to be Deleted";
  read dir;
  if [ -d $dir ]
  then
     rmdir $dir;
     echo "Directory deleted Successfully!!!";
     echo "Deleted Directory Can be Checked from the following table";
     ls -t | head -n 15
  else
     echo "No such Directory Exists!!!";
  fi
  ;;
3)
  echo "Changing Current Working Directory To:";
  cd /home/redhat/dm/a
  pwd
  echo "The Node Details Of Each File In The Working Directory Is As Follows:";
  ls -i
  ;;
4)
  exit;
  ;;

esac
done

No comments:

Post a Comment