View difference between Paste ID: v5LbbGVV and wv5erGvc
SHOW: | | - or go back to the newest paste.
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 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"
6
        read option
7
       
8
        # Ask for the path of file to perform the operations
9
        printf "\nEnter the path to the file:\n"
10
        read path
11
 
12
        # Perform appropriate operations according to the options
13
        case $option in
14
                # Execute the wc command foe the file
15
                1 ) wc $path ;;
16
17
                # Display first 10 lines of a file
18
                2 ) head $path ;;
19
20
                # Show first the last 10 lines of a file
21
                3 ) tail $path ;;
22
23
                # Display file before and afer sorting
24
                4 )
25-
                        printf "before sorting\n"
25+
                        printf "\nBefore sorting\n"
26
                        cat $path
27
28
                        sort $path
29
30-
                        printf "After sorting\n"
30+
                        printf "\nAfter sorting\n"
31
                        cat $path
32
                ;;
33
        esac
34
 
35
        read
36
        menu
37
}
38
 
39
menu