How can the script below be made to always work no matter the filenames returned by find ?
#!/bin/sh
cmds_should_always_work() {
echo "\n\n*********************************" $1
stat --printf='%n' -- "$1" || echo STATFAILED
echo "\n----------------\n"
lsattr -d -- "$1" || echo LSATTRFAILED
echo "\n----------------\n"
};
for item in $(find "$1" -maxdepth 1 -mindepth 1); do cmds_should_always_work "${item}"; done
For example files in the find directory that contain a new line break this script.
Further if the find directory is named e.g. $schema, this script returns the parent directory. How can this be avoided by the script vs. having to supply and escaped path somepath/\$schema to the script?
exec
option of find instead offor
loop. – Prvt_Yadav Mar 14 '19 at 02:21