View difference between Paste ID: NKPyWVsV and rsDBJSzv
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 on your filen\n\t1. Word Count of a file\n\t2. First 10 lines of a file\n\t3. Last 10 lines of a 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 "\nBefore sorting:\n"
26
                        cat $path
27
28-
                        sort $path
28+
                        sort -k1 $path
29
30
                        printf "\nAfter sorting:\n"
31
                        cat $path
32
                ;;
33
        esac
34
 
35
        read
36
        menu
37
}
38
 
39
menu