Find command can do more - Linux life hacks series



 A Linux life hack that actually saves time

The find command can do more than just search for files — it can also perform actions on them directly using the -exec option.

Example:

$ find ~/ -type f -exec ls -lah {} \;

What happens here:
find locates all files and, for each one, runs ls, displaying permissions, size, and metadata.

How -exec works:

  • -exec ls — the command to execute

  • -lah — output format (permissions, hidden files, sizes)

  • {} — substituted with each found file name

  • \; — terminates the command (escaped so the shell doesn’t interpret it)

Why it’s useful:
It allows you to apply a single action to many files across different directories.

Important:
You can use + instead of \;.
In that case, the command is applied to a group of files at once — faster and more efficient.

Example with multiple commands:

$ find . -name "*.txt" -exec wc {} \; -exec du -sh {} \;

This counts words and immediately shows the size of each file.

Additional tip💡

Need to quickly find executable files in a directory?  

Use find with the -executable flag — it will show only those files that can actually be run.

Example:

$ find . -type f -executable

Unlike permission checks with -perm, this option takes real permissions and ACL into account, so the result is more accurate — the output includes only those files that are executable by the current user.

Save this — it’s a fundamental technique for working with files in Linux.