LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-03-2020, 12:13 AM   #1
aristosv
Member
 
Registered: Dec 2014
Posts: 263

Rep: Reputation: 3
export variables while defining them


right now I am using this script to read from file.txt and create a few variables.

Code:
while read value1 value2 value3
do
 some stuff
done < file.txt
Is there a way to also export these variables while reading them from file.txt without having to export them one by one?

Code:
export value1 value2 value3
Thanks
 
Old 02-03-2020, 06:05 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,638

Rep: Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697
short answer: yes.

have you tried? Did you read the mam page on your shell?
 
Old 02-03-2020, 07:24 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
ah no, I'd think not. If you have a semi automatic, or a fully automatic rifle. Pull the trigger. How many bullets can come out of the barrel of the rifle at the same time?

unless you have threads and program it as such to fire off "items" simultaneously.

but too, I have not read the mam page on your, or my shell. said to not conflict with wpeckham answer, only to point out basic logical progressions which strongly suggests nope.

one path, one in one out, two paths, spawn more than one, increase the path width, then put them out at the same time.

two or more threads one process controlling them.

Last edited by BW-userx; 02-03-2020 at 07:38 AM.
 
Old 02-03-2020, 11:50 AM   #4
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,138
Blog Entries: 6

Rep: Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827
Simple example:
Code:
cat file.txt
The big brown dog is sleeping

while read a b c; do
    export A="$a"
    export B="$b"
    export C="$c"
done < file.txt

for i in "$A" "$B" "$C"; do
    echo "$i"
done

The
big
brown dog is sleeping

export -p
declare -x A="The"
declare -x B="big"
declare -x C="brown dog is sleeping"
 
  


Reply



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
Defining Global Variables in the kernel crunchyblack Programming 4 10-20-2008 10:52 AM
defining environmental variables? sarayazdani LinuxQuestions.org Member Intro 1 08-05-2008 04:08 AM
Do you make prototypes of functioned before defining them? RHLinuxGUY Programming 3 05-13-2006 07:56 AM

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

All times are GMT -5. The time now is 01:22 AM.

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