I’m wondering what is the syntax error in my command I’m using.
In the current directory I use the command ls -l to retrieve file permissions in my directory.
How would I do a query to see which files are readable, writeable, and executable by the user and then print a filtered list using awk?
I know the bits I’m interested in are the second, third, and fourth.
For example,
-rw-r----- .. .. .. ..
or
drw-r----- .. .. .. ..
I have an awk command as follows:
ls -l | awk '{if{$1 == /.rwx....../}print "line"}'
I’ve tried many things but there’s still a syntax error.
Any help is greatly appreciated! Thanks in advance!
The operator used to check if a string matches a regular expression is
~, not==. Also, use()around the condition in theifstatement: