LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-09-2023, 04:39 AM   #1
shirase
LQ Newbie
 
Registered: Nov 2023
Distribution: Linux for PlayStation 2
Posts: 8

Rep: Reputation: 0
Question Subshell Assigned Variables vs. Functions


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" ;)" ;
 
Old 12-09-2023, 05:23 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,863

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
the first one is a function, the second one is a variable.
 
  


Reply

Tags
awk, function, random, subshell, variable



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to identify the list of all "assigned functions" of keycodes ajaygarg Linux - Newbie 3 02-28-2012 01:51 AM
dvd has no URL assigned, so I can't play dvd's(no url assigned is the error message) Zych Linux - Newbie 3 08-01-2010 07:26 AM
bash script and exporting variables into a subshell spork Programming 3 10-14-2008 11:38 PM
mc subshell.c: read (subshell_pty...): rickenbacherus Linux - Software 2 07-14-2004 07:14 PM
Continuing a script on a new subshell dpillay Programming 2 05-29-2004 07:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration