Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This functions prints the menu, ask for the path of file and perform appropriate operations on that file
- menu() {
- clear
- printf "Here are the operations you can do to your filen\n\t1. Word Count\n\t2. First 10 lines of file\n\t3. Last 10 lines of file\n\t4. Content of file before and after sorting\n\t"
- read option
- # Ask for the path of file to perform the operations
- printf "\nEnter the path to the file:\n"
- read path
- # Perform appropriate operations according to the options
- case $option in
- # Execute the wc command foe the file
- 1 ) wc $path ;;
- # Display first 10 lines of a file
- 2 ) head $path ;;
- # Show first the last 10 lines of a file
- 3 ) tail $path ;;
- # Display file before and afer sorting
- 4 )
- printf "\nBefore sorting\n"
- cat $path
- sort $path
- printf "\nAfter sorting\n"
- cat $path
- ;;
- esac
- read
- menu
- }
- menu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement