| #!/bin/bash | |
|  | |
| 
 | |
| listandReturn() {  | |
| 	printf "Listing contents of %s.\\n" "$1" | |
| 	ls -rc "$1" | awk -F '/' '{print $NF}' | nl | |
| 	read -erp "Pick an entry by number to $2, or press ctrl-c to cancel. " number | |
| 	chosen="$(ls -rc "$1" | nl | grep -w  "$number" | awk '{print $2}')" | |
| 	basefile="$(basename "$chosen")" && base="${basefile%.*}" | |
| } | |
| 
 | |
| listandReturn ~/.openvpn/UDP\ 1194\ Normal/ | |
| 
 | |
| sudo openvpn --config ~/.openvpn/UDP\ 1194\ Normal/${basefile}
 |