SHOW:
|
|
- or go back to the newest paste.
| 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 | - | 1 ) |
| 20 | + | # This option count the number of words,characters and line in the file |
| 21 | - | # This option count the number of words,characters and line in the file |
| 21 | + | 1 ) wc $path ;; |
| 22 | - | wc $path |
| 22 | + | |
| 23 | # This option displays the first 10 lines of file | |
| 24 | - | 2 ) |
| 24 | + | 2 ) head $path ;; |
| 25 | - | # This option displays the first 10 lines of file |
| 25 | + | |
| 26 | - | head $path |
| 26 | + | # This option displays the last 10 lines of file |
| 27 | 3 ) tail $path ;; | |
| 28 | - | 3 ) |
| 28 | + | |
| 29 | - | # This option displays the last 10 lines of file |
| 29 | + | # This function display the file before sorting and after sorting |
| 30 | - | tail $path |
| 30 | + | |
| 31 | printf "before sorting\n" | |
| 32 | cat $path | |
| 33 | - | # This function display the file before sorting and after sorting |
| 33 | + | |
| 34 | printf "After sorting" | |
| 35 | cat $path | |
| 36 | ;; | |
| 37 | esac | |
| 38 | ||
| 39 | menu | |
| 40 | } | |
| 41 | ||
| 42 | menu |