samroar04

Untitled

Jan 28th, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #This functions prints the menu and takes the menu option input
  2. menu() {
  3. #Ask for the path of file to perform the operations
  4. echo "Enter the path to the file"
  5. read path
  6.  
  7. echo "Here are the operation you can do to your file
  8. 1. Word Count
  9. 2. First 10 lines of file
  10. 3. Last 10 lines of file
  11. 4. Content of line before and after sorting"
  12.  
  13. echo "Choose your option"
  14. read option
  15.  
  16. #Call appropriate function according to the operation you want to perform
  17. case $option in
  18. # this option count the number of words,characters and line in the file
  19. 1 ) wc $path ;;
  20. # this option displays the first 10 lines of file
  21. 2 ) head $path ;;
  22. #this option displays the last 10 lines of file
  23. 3 ) tail $path ;;
  24. 4 ) sorting ;;
  25. esac
  26.  
  27. menu
  28. }
  29.  
  30. #This function display the file before sortinf and after sorting
  31. sorting() {
  32. echo "before sorting"
  33. cat $path
  34. sort $path
  35. echo "After sorting"
  36. cat $path
  37. }
  38.  
  39. menu
Advertisement
Add Comment
Please, Sign In to add comment