i have a bash shell script and i press enter and the script still continues on? how do i stop this
Depends what you're doing in the first place. Show your script and show the manner which you're running it.
ok
read "enter case filename " testfile
ls testfile 2> /dev/null || exit (0 or 1 or 2)
echo "case file found"
cat case
basically they have to enter "case" and if they enter "testfile" it should display an error message(cant figure out how to do that) but then it should display contents of the case file if the user entered case
but i just press enter and it goes through the whole script:confused:
First, read doesn't work like that.
printf "enter case filename "
read filename
Second, variables don't work that way.
ls $testfile 2> /dev/null
Third, exit doesn't work that way.
ls $testfile 2> /dev/null || exit 1
Fourth, there's much easier and more efficient ways to do this than ls.
printf "enter case filename "
read filename
[ -f "$filename" ] || exit 1
echo "Found $filename"