June 2017
Beginner
502 pages
11h 26m
English
The double semicolon is a case construct option terminator. We will see the case constructor later in this book, but as of now, just think of it as a sequence of if/then/else, which is widely adopted to create a user menu:
#!/bin/shclearecho "Please choose between these options:"echo "ls for listing files"echo "procs for listing processes"echo "x for exit"read inputcase "$input" in "ls" | "LS" ) echo "Listing files:" ls exit 0 ;;"procs" | "PROCS") echo "Listing processes:" ps exit 0 ;; "x" | "X" ) echo "exiting" exit 0 ;; * ) # Default catchall option echo "exiting" exit 0 ;; esac
As you can see, the case construct starts with the case keyword and is closed by the reverse of it: esac. What it does is try ...
Read now
Unlock full access