Instead, run du only on the symlinks that were successfully created.
for len in $symlink_name_lengths; do
name=`yes|tr '\n' y|head -c$len`
# Ignore failures.
- ln -fs $name $len > /dev/null 2>&1
+ ln -fs $name $len > /dev/null 2>&1 && symlinks="$symlinks $len"
done
-# Redirect errors (e.g. missing file) to /dev/null.
-du -a $symlink_name_lengths > out 2> /dev/null || fail=1
+du -a $symlinks > out || fail=1
# Require that at least one of these symlinks has a non-zero size.
grep '^[1-9]' out > /dev/null || fail=1