Search code examples
unixawkls

Handling file permissions in UNIX using awk


I want to know which permission is given to a file using a shell script. So i used the below code to test for a file. But it shows nothing in output. I just wanted to know where i have made the mistake. Please help me. The file "1.py" has all read write and execute files enabled.

 ls -l 1.py | awk ' {if($1 -eq "-rwxrwxrwx")print 'True'; }'

Solution

  • in awk, you shouldn't write shell test, e.g. [[ ... -eq ...]], you should do it in awk way:

    if($1=="whatever")...