I'd like to rewrite these 2 commands so they will use only POSIX-compliant switches:
find "$TARGET_DIR" -maxdepth 1 -type d -printf '(DIR) %f\n'
find "$TARGET_DIR" -maxdepth 1 -type f -printf '%s %f ' -exec file -b {} \;
-maxdepth 1
can probably be replaced with -prune
, but -printf
will require a more complicated redirection.
printf '(DIR) %s\n' "$TARGET_DIR/"*/
should work for the first, I think, but just to be sure - what does%f
do (I forget?).-prune
equates to-maxdepth 0
not-maxdepth 1
. Related: Limit POSIX find to specific depth?