Search code examples
linuxbashfile-permissions

How can I test existence of a file with permissions 000?


For some reason I'm not aware of, I've a file with permissions set to '000'.

I'd like to chmod u+r it, because I need to zip its entire folder. And with 000, zip warn about a problem reading this file.

I'd like to test existence of this file, because not every time I've it into the folder.

But I verified that using the following results is a boolean false

if [ -f $file_path ]; then 
...

Also the -e switch return false.

How can I test if file exists from a bash script ?


Solution

  • You can search a directory for files that have 000 permissions with this statement:

    find /tmp  -perm 000
    

    where /tmp would be your directory.