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
I struggled with this on Mac OS X where the find command doesn't support
-printf
.A solution that I found, that admittedly relies on the 'group' for all files being 'staff' was...
This splits the ls long output into three tokens
And then outputs tokens 2 and 3, i.e. output is number of bytes and then filename
You could try this:
This will give you the size in bytes. But the du command also accepts the parameters -k for KB and -m for MB. It will give you an output like