I'm trying to write a script that will look for a certain .txt file saved to my desktop. I want the script to be able to check if this file exists and then check to see if it is readable and writable.
Any hints?
I'm trying to write a script that will look for a certain .txt file saved to my desktop. I want the script to be able to check if this file exists and then check to see if it is readable and writable.
Any hints?
You needn't check if it exists, the checks for read and write permissions are enough:
From
help test
, a selection of relevant tests:So you can try:
The return code is 0 if it is both readable and writeable.