Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #1) make a getname function that will prompt for filename
- function getname(){
- trap control_c SIGINT
- local fname=$1;
- #if there is no input prompt user for file name
- if [ ! $1 ]; then
- read -p "Enter a file name: " fname;
- fi;
- #until grep is given a valid file name
- until ( grep -E '^[a-zA-Z_]w+$' <<< "$fname" > /dev/null 2>&1); do
- #this is were the error is
- if echo "$fname" | grep -E '/';
- then #this tests if fname is a file directory
- echo "Paths are not a legal file name.";
- fi;
- read -p "Enter a legal file name: " fname;
- done
- echo "$fname"
- }
Add Comment
Please, Sign In to add comment