If I issue the find command as follows:
$ find . -name *.ear
It prints out:
./dir1/dir2/earFile1.ear
./dir1/dir2/earFile2.ear
./dir1/dir3/earFile1.ear
What I want to 'print' to the command line is the name and the size:
./dir1/dir2/earFile1.ear 5000 KB
./dir1/dir2/earFile2.ear 5400 KB
./dir1/dir3/earFile1.ear 5400 KB
just the h extra from jer.drab.org's reply. saves time converting to MB mentally ;)
Scripter World reference
Using gnu find, I think this is what you want. It finds all real files and not directories (-type f), and for each one prints the filename (%p), a tab (\t), the size in kilobytes (%k), the suffix " KB", and then a newline (\n).
If the printf command doesn't format things the way you want, you can use exec, followed by the command you want to execute on each file. Use {} for the filename, and terminate the command with a semicolon (;). On most shells, all three of those characters should be escaped with a backslash.
Here's a simple solution that finds and prints them out using "ls -lh", which will show you the size in human-readable form (k for kilobytes, M for megabytes):
As yet another alternative, "wc -c" will print the number of characters (bytes) in the file:
Why not use du -a ? E.g.
Works on a Mac
This gives you the filesize only, instead of all the unnecessary stuff.