Skip to content
Advertisement

How to omit the result after I get the result in Linux?

I am writing a code using Linux. I used the ‘until’ function to find my file however I am unable to remove the result once I found it. Any guidance?

My code:

until find $filename
do
  echo "Please re-enter text file name:"
  read filename
done

Result:

Enter text file name: process.txt
process.txt <- need to remove this

Advertisement

Answer

The output you are trying to discard is coming from find. Either redirect it to /dev/null, or use:

until test -e "$filename"; do
        echo "Please re-enter text file name:"
        read filename
done
Advertisement