Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This functions prints the menu and takes the menu option input
- menu() {
- #Ask for the path of file to perform the operations
- echo "Enter the path to the file"
- read path
- echo "Here are the operation you can do to your file
- 1. Word Count
- 2. First 10 lines of file
- 3. Last 10 lines of file
- 4. Content of line before and after sorting"
- echo "Choose your option"
- read option
- #Call appropriate function according to the operation you want to perform
- case $option in
- # this option count the number of words,characters and line in the file
- 1 ) wc $path ;;
- # this option displays the first 10 lines of file
- 2 ) head $path ;;
- #this option displays the last 10 lines of file
- 3 ) tail $path ;;
- 4 ) sorting ;;
- esac
- menu
- }
- #This function display the file before sortinf and after sorting
- sorting() {
- echo "before sorting"
- cat $path
- sort $path
- echo "After sorting"
- cat $path
- }
- menu
Advertisement
Add Comment
Please, Sign In to add comment