Bash find command input

Hi, I'm try to write a bash file that searches for all file names and then outputs whether those files are readable, writable and or executable. I managed to get this working when I manually input the file names but I want it to search for all file names in all subdirectories and I'm not sure what's wrong with the code. It would be greatly appreciated if you could let me know what I've done wrong.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

files=$({find. -type f ;})

for var in "$files"
do
# find out if file has write permission or not
[ -w $var ] && W="Write = yes" || W="Write = No"
 
# find out if file has excute permission or not
[ -x $var ] && X="Execute = yes" || X="Execute = No"
 
# find out if file has read permission or not
[ -r $var ] && R="Read = yes" || R="Read = No"
 
echo "File name: $var"
echo "$W"
echo "$R"
echo "$X"

done
You have three errors - two on line 3 and one on line 5:

One error on line 3 is explained here: http://www.tldp.org/LDP/abs/html/commandsub.html
The other is probably a typo.

For the error on line 5, see here: http://www.tldp.org/LDP/abs/html/quotingvar.html

Try asking on another forum, this maybe.
http://www.programmingforums.org/forum26.html
Since this is a C++ site.
Topic archived. No new replies allowed.