Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- getFile(){
- clear
- PS3="Please Select a File: "
- options=($(find -maxdepth 1 -print0|xargs -0))
- select opt in "${options[@]}" "Quit";
- do
- if (( REPLY == 1 + ${#options[@]}))
- then
- exit
- elif (( REPLY > 0 && REPLY <= ${#options[@]} ))
- then
- opt=$(basename $opt)
- echo "Your file is $opt"
- break
- else
- echo "Not a Valid option. Please Try again."
- fi
- done
- FILE="`pwd`/$opt"
- }
- if [ ! -f "$FILE" ]
- then
- while [ 1 ]
- do
- getFile
- [[ -d "$FILE" ]] && cd "$FILE"
- [[ -f "$FILE" ]] && break
- done
- fi
- cat "$FILE"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement