উত্তর:
এটি উপস্থিত আছে কিনা তা আপনার চেক করার দরকার নেই, পড়ার এবং লেখার অনুমতিগুলির জন্য চেকগুলি যথেষ্ট:
help testপ্রাসঙ্গিক পরীক্ষার একটি নির্বাচন থেকে :
-a FILE True if file exists.
-e FILE True if file exists.
-f FILE True if file exists and is a regular file.
-r FILE True if file is readable by you.
-s FILE True if file exists and is not empty.
-w FILE True if the file is writable by you.
সুতরাং আপনি চেষ্টা করতে পারেন:
FILE="/path/to/some/file"
if [[ -r $FILE && -w $FILE ]]
then
# do stuff
else
# file is either not readable or writable or both
fi
if [[ -r $FILE ]] && [[ -w $FILE ]]পরিবর্তে হওয়া উচিত নয় if [[ -r $FILE && -w $FILE ]]?
&&ইত্যাদি অনুমতি দেওয়া হয়[[
-rএবং-wঅপারেটরগুলি ব্যবহার করুন