Linux – Print full path of files and sizes with find in Linux

bashfindlinuxls

Here are the specs: Find all files in / modified after the modification time of /tmp/test, exclude /proc and /sys from the search, and print the full path of the file along with human readable size. Here is what I have so far:

find / \( -path /proc -o -path /sys \) -prune -o -newer /tmp/test -exec ls -lh {} \; | less

The issue is that the full path doesn't get printed. Unfortunately, ls doesn't support printing the full path! And all solutions I have found that show how to print the full path suggest using find. 😐

Any ideas? Thanks!

Best Answer

Instead of -exec ls -lh {} \; you can also use the printf option:

find / \( -path /proc -o -path /sys \) -prune -o -newer /tmp/test -printf "%s %p\n" | less

Although that will just print the size in bytes and not in the nice human-readable format ls supports.

Related Question