check if file is readable by others

hi all,
in ksh script how do i detect if a file is readable by others ??

thanks.

ls -l file | awk '{if($1 ~ /.r..r..r../)print "File is readable by all";}'
[[ `stat --print=%A $1 | cut -c 8` = "r" ]] && echo "yes,readable for others"
if ls -ld somefile | grep -q ^-......r; then 
  echo world readable file
fi
[ "$(find "$filename" -perm -004)" ]

Cheers,
Alister

-perm -004 , no?

1 Like

Woops! Indeed. Fixed. Thank you for catching that. :slight_smile: