find . -maxdepth 1 -exec stat -c '%a %n' {} +

let’s break down this bash command step by step

  1. find .: This command starts searching in the current directory (.).

  2. -maxdepth 1: This option restricts the search to only the current directory, not any subdirectories. So it won’t go deeper than one level down.

  3. -exec: This option executes a specified command for each matched file.

  4. stat -c '%a %n' {} +: This is the command that will be executed for each file found. Here’s what it does:

    stat: This command displays file or file system status. -c '%a %n': This option specifies the format for the output of stat. %a displays the access permissions in octal (like 755, 644, etc.), and %n displays the file name. {}: This is a placeholder for each file found by find. +: This indicates the end of the -exec command.

So, in simple terms, this bash command finds all files in the current directory (not in subdirectories), then for each file found, it displays the file’s access permissions in octal format followed by its filename.