Agnus Dei (jackal) wrote,
Agnus Dei
jackal

Passing variable outside of while loop in bash

This is throw away code.

But it shows how to pass a variable outside of a while loop in bash:

find . -type f -size +1000k -print0 | {
while IFS= read -r -d '' file; do
        FOO="$FOO `stat -r "$file" | gawk '{print $8}'| tr '\n' ' '`"   # Return the size without a new line at the end
        FOO="$FOO `echo  \"$file\"`\n"                                  # Return the file name WITH a new line at the end
done
echo -ne "$FOO" | sort -rn      # return sorted results
}
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments