Shakil Ahamed
Shakil Ahamed

Reputation: 577

Ubuntu find command and printf argument

I was trying to search a file which is 1033 bytes size. After half hour googling I find a command which show all file name and size inside the current directory.

find -printf 'Name: %16f Size: %6s\n'

How %16f and %6s show the name and file size?

Upvotes: 0

Views: 786

Answers (1)

devnull
devnull

Reputation: 123608

I was trying to search a file which is 1033 bytes size.

You can say:

find . -type f -size 1033c

%f and %s are directives for the printf option:

          %f     File's name with any leading  directories  removed  (only
                 the last element).

          %s     File's size in bytes.

Saying %16f would pad the filename; be warned that the output might be truncated if the filename exceeds 16 characters.

Upvotes: 1

Related Questions