Find all writable files in the current directory

后端 未结 10 448
[愿得一人]
[愿得一人] 2020-12-25 11:47

I want to quickly identify all writable files in the directory. What is the quick way to do it?

10条回答
  •  感情败类
    2020-12-25 12:28

    to find writable files regardless of owner, group or others, you can check the w flag in the file permission column of ls.

    ls -l | awk '$1 ~ /^.*w.*/'
    

    $1 is the first field, (ie the permission block of ls -l) , the regular expression just say find the letter "w" in field one. that's all.

    if you want to find owner write permission

    ls -l | awk '$1 ~ /^..w/'
    

    if you want to find group write permission

    ls -l | awk '$1 ~ /^.....w/'
    

    if you want to find others write permission

    ls -l | awk '$1 ~ /w.$/'
    

提交回复
热议问题