samroar04

Untitled

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