Advertisement
achshar

Untitled

Jan 28th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. # This option count the number of words,characters and line in the file
  21. 1 ) wc $path ;;
  22.  
  23. # This option displays the first 10 lines of file
  24. 2 ) head $path ;;
  25.  
  26. # This option displays the last 10 lines of file
  27. 3 ) tail $path ;;
  28.  
  29. # This function display the file before sorting and after sorting
  30. 4 )
  31. printf "before sorting\n"
  32. cat $path
  33. sort $path
  34. printf "After sorting"
  35. cat $path
  36. ;;
  37. esac
  38.  
  39. menu
  40. }
  41.  
  42. menu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement