Subshell Assigned Variables vs. Functions
by shirase from LinuxQuestions.org on (#6H0X4)
This question might just be dumb and I really try not to ask things that I can do by myself or research to answer.
But I've been going through forums, manuals, dev blogs and just the obscurely unorganized internet with no results.
I created a more entropic RANDOM variable and I can enclose it with in a subshell and either assign it to a variable or a function.
tldr; Is there's a difference in the 2 examples below?
Code:RANDOM () {
awk 'BEGIN { srand(); print int(rand()*32768) }' "/dev/null" ;
} ;
RANDOM="$(awk 'BEGIN { srand(); print int(rand()*32768) }' "/dev/null" ;)" ;
But I've been going through forums, manuals, dev blogs and just the obscurely unorganized internet with no results.
I created a more entropic RANDOM variable and I can enclose it with in a subshell and either assign it to a variable or a function.
tldr; Is there's a difference in the 2 examples below?
Code:RANDOM () {
awk 'BEGIN { srand(); print int(rand()*32768) }' "/dev/null" ;
} ;
RANDOM="$(awk 'BEGIN { srand(); print int(rand()*32768) }' "/dev/null" ;)" ;