Advertisement
samroar04

Untitled

Jan 28th, 2014
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 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\n"
  10.  
  11. printf "Choose your option\n"
  12. read option
  13.  
  14. # Ask for the path of file to perform the operations
  15. printf "Enter the path to the file:\n"
  16. read path
  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. # This option displays the first 10 lines of file
  23. 2 ) head $path ;;
  24. # This option displays the last 10 lines of file
  25. 3 ) tail $path ;;
  26. # This function display the file before sorting and after sorting
  27. 4 )
  28. printf "before sorting\n"
  29. cat $path
  30. sort $path
  31. printf "After sorting"
  32. cat $path
  33. ;;
  34. esac
  35.  
  36. menu
  37. }
  38.  
  39. menu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement