samroar04

Untitled

Jan 28th, 2014
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. # This functions prints the menu, ask for the path of file and perform appropriate operations on that file
  2. menu() {
  3. clear
  4.  
  5. printf "Here are the operations 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\n"
  10. read option
  11.  
  12. # Ask for the path of file to perform the operations
  13. printf "\nEnter the path to the file:\n"
  14. read path
  15.  
  16. # Perform appropriate operations according to the options
  17. case $option in
  18. # Execute the wc command foe the file
  19. 1 ) wc $path ;;
  20.  
  21. # Display first 10 lines of a file
  22. 2 ) head $path ;;
  23.  
  24. # Show first the last 10 lines of a file
  25. 3 ) tail $path ;;
  26.  
  27. # Display the file before and afer sorting
  28. 4 )
  29. printf "before sorting\n"
  30. cat $path
  31. sort $path
  32.  
  33. printf "After sorting"
  34. cat $path
  35. ;;
  36. esac
  37.  
  38. read
  39. menu
  40. }
  41.  
  42. menu
Advertisement
Add Comment
Please, Sign In to add comment