Maybe it's worth noting that
ls -Ri | awk '{print $1}'
does effectively the same thing as the OP's example, on all platforms in question. I get that -printf "%i \n" may have just been a generic "for instance," though.
If you need a solution that is relatively certain to work in both GNU and BSD-ish environments, you can define a function which handles the underlying implementation details. However, this gets gnarly quick (as you'll see), and you have to start accounting for things like how to use xargs -I{} and still accommodate filenames with whitespace.
But if you're up for all that:
stat_inode_number() { if [ "$(uname -s)" = "Linux" ]; then # not sure if OP's trailing space was intentional, but keeping it here stat -c '%i ' "$@" else stat -f '%i ' "$@" fi } # export function to subshells, e.g., pipes export -f stat_inode_number find . -print0 | xargs -I{} -0 sh -c "stat_inode_number '{}'"
To briefly answer Bruce Sun's question from above, of what to do if the existing stat formats don't suit your needs: you're either in basename territory at that point, or you need to look into Bash parameter expansion (e.g., ${var##*/}), both of which are beyond the scope here.
%i(inode number) was used as an example whenls -Riwould seem to be the preferred tool for the job there, and about the trailing space before the newline. Could the OP chime in on that?