Try reading the stat man page and running stat --format=%s
on some file to see what that does.
to see what $( ... )
Read the find man page's entry on -print0 to see how that makes find
's output be a list of filenames separated by the ASCII NUL character and read this
for more on what the NUL character is/does.
In IFS= read -r -d '' file
, the IFS=
sets IFS to an empty string during execution of the following read
. This seldom-used bash feature is briefly described here
where it says "Otherwise, the variables are added to the environment of the executed command and do not affect the current shell environment
". The effect of this on read
is described later in this post.
Use help read
at a command prompt (or the bash man page) for information on the read
option prevents any "escape sequences" in the file name being processed -- so the characters in the find
output are read exactly as find
option sets the delimiter that read
uses to break the input. By default, it is line end so read processes each line until there are no lines left. Setting the delimiter to the empty string actually sets it to the NUL character (internally values in bash variables are terminated with a NUL character -- this is standard for strings in the C programming language), so read
will return each time it gets a file name from find (remember the -print0
is making find
separate file names with a NUL?).
puts each file name into the variable "file". Normally it strips off any characters in IFS from the beginning and end of its input pieces. IFS is normally set to space, tab and line end so you don't want that in case there are file names that have any of those characters at beginning or end of their names. Setting IFS to the empty string means you get the file name exactly as find