I what to prompt a user to enter name of a file, read that into a variable, and use that variable to check if the valued enter is in fact a legimate file.
How would I do this in a ksh script? Thanks
You know already how to read user input , here's the new part:
It's done with test(1) :
test -f $theFile && echo exists
It also has the alternate name [
which is most often used in if
or while
expressions:
if [ -f $theFile ]
then
echo exists
fi
Please refer to the above link (or alternatively the manual page).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.