El siguiente es el preámbulo del archivo sudoers
en mi Mac. (No creo que su redacción haya cambiado en los últimos quince años.)
This file MUST be edited with the 'visudo' command as root. Failure to use 'visudo' may result in syntax or file permission errors that prevent sudo from running.
See the sudoers man page for the details on how to write a sudoers file.
Aquí hay un fragmento devisudo man page
:
After the edits are made, visudo parses the sudoers file. It will not save the changes if there is a syntax error.
Upon finding an error, visudo will print a message stating the line number(s) where the error occurred and the user will receive a "What now?" prompt. At this point, the user may enter e to re-edit the sudoers file, x to exit without saving the changes, or Q to quit and save changes.
The Q option should be used with extreme care because if visudo believes there is a parse error, so will sudo, and no one will be able to sudo again until the error is fixed. If e is typed to edit the sudoers file after a parse error has been detected, the cursor will be placed on the line where the error occurred.
... Y esa es la razón por la que en realidad usovisudo
en lugar de, digamos, nano
. Si hay un problema, visudo
me advertirá y me dirigirá a él antes de comprometerme y bloquear no solo a mí, sino a todos fuera del acceso de root. (Como lo hice yo hace quince años, no es que lo admita. )De todos modos, dado que $sudo
se queja de un error de sintaxis en un número de línea no existente -, apuesto a que es un carácter EOF extraviado o un error tipográfico similar que causa el problema.
Попробуйте это:
#!/bin/bash
while read file; do
stat -c '%A %n' "$file" >> $(stat -c '%a' "$file").txt
done < <(find "$1")
Использование:
./script.sh /path/to/directory
stat -c '%A %n' "$file"
печатает разрешения и путь к файлу, например.-rw-rw-rw- /foo/bar
stat -c '%a' "$file"
печатает разрешения в восьмеричной форме, например.666
Вывод первого stat
добавляется к имени файла, созданному вторым stat
, с суффиксом .txt
.