take input from a Variable and store it into same variable but in a diff file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












Input file : input.txt



l1="R2"
l2="R1"


"Another file name : output.sh"



l1=""
l2=""


I want to copy the value of variables l1,l2 from input.txt to a file variable l1,l2 of file output.sh







share|improve this question

















  • 1




    As the question is described, the following answer your question: cp input.txt output.sh - did I answer your question? if not - please update your question to describe the problem in a better way.
    – Yaron
    Jul 18 at 13:55











  • i am trying that only R2 should stored in the variable l1, the way you told will copy all the contents of input file in output.sh
    – Shubham Jain
    Jul 18 at 13:59











  • I want only the value of variable i.e text between " " to go into another file of same variable
    – Shubham Jain
    Jul 18 at 14:01











  • What is "a file of that variable"?
    – L. Scott Johnson
    Jul 18 at 14:02
















up vote
0
down vote

favorite












Input file : input.txt



l1="R2"
l2="R1"


"Another file name : output.sh"



l1=""
l2=""


I want to copy the value of variables l1,l2 from input.txt to a file variable l1,l2 of file output.sh







share|improve this question

















  • 1




    As the question is described, the following answer your question: cp input.txt output.sh - did I answer your question? if not - please update your question to describe the problem in a better way.
    – Yaron
    Jul 18 at 13:55











  • i am trying that only R2 should stored in the variable l1, the way you told will copy all the contents of input file in output.sh
    – Shubham Jain
    Jul 18 at 13:59











  • I want only the value of variable i.e text between " " to go into another file of same variable
    – Shubham Jain
    Jul 18 at 14:01











  • What is "a file of that variable"?
    – L. Scott Johnson
    Jul 18 at 14:02












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Input file : input.txt



l1="R2"
l2="R1"


"Another file name : output.sh"



l1=""
l2=""


I want to copy the value of variables l1,l2 from input.txt to a file variable l1,l2 of file output.sh







share|improve this question













Input file : input.txt



l1="R2"
l2="R1"


"Another file name : output.sh"



l1=""
l2=""


I want to copy the value of variables l1,l2 from input.txt to a file variable l1,l2 of file output.sh









share|improve this question












share|improve this question




share|improve this question








edited Jul 18 at 13:54









Yaron

3,18421026




3,18421026









asked Jul 18 at 13:52









Shubham Jain

51




51







  • 1




    As the question is described, the following answer your question: cp input.txt output.sh - did I answer your question? if not - please update your question to describe the problem in a better way.
    – Yaron
    Jul 18 at 13:55











  • i am trying that only R2 should stored in the variable l1, the way you told will copy all the contents of input file in output.sh
    – Shubham Jain
    Jul 18 at 13:59











  • I want only the value of variable i.e text between " " to go into another file of same variable
    – Shubham Jain
    Jul 18 at 14:01











  • What is "a file of that variable"?
    – L. Scott Johnson
    Jul 18 at 14:02












  • 1




    As the question is described, the following answer your question: cp input.txt output.sh - did I answer your question? if not - please update your question to describe the problem in a better way.
    – Yaron
    Jul 18 at 13:55











  • i am trying that only R2 should stored in the variable l1, the way you told will copy all the contents of input file in output.sh
    – Shubham Jain
    Jul 18 at 13:59











  • I want only the value of variable i.e text between " " to go into another file of same variable
    – Shubham Jain
    Jul 18 at 14:01











  • What is "a file of that variable"?
    – L. Scott Johnson
    Jul 18 at 14:02







1




1




As the question is described, the following answer your question: cp input.txt output.sh - did I answer your question? if not - please update your question to describe the problem in a better way.
– Yaron
Jul 18 at 13:55





As the question is described, the following answer your question: cp input.txt output.sh - did I answer your question? if not - please update your question to describe the problem in a better way.
– Yaron
Jul 18 at 13:55













i am trying that only R2 should stored in the variable l1, the way you told will copy all the contents of input file in output.sh
– Shubham Jain
Jul 18 at 13:59





i am trying that only R2 should stored in the variable l1, the way you told will copy all the contents of input file in output.sh
– Shubham Jain
Jul 18 at 13:59













I want only the value of variable i.e text between " " to go into another file of same variable
– Shubham Jain
Jul 18 at 14:01





I want only the value of variable i.e text between " " to go into another file of same variable
– Shubham Jain
Jul 18 at 14:01













What is "a file of that variable"?
– L. Scott Johnson
Jul 18 at 14:02




What is "a file of that variable"?
– L. Scott Johnson
Jul 18 at 14:02










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










If you need to output.sh to accomplish the assignments given in input.txt, you could source the input file



So this would be the content of output.sh



l1="" # not needed
l2="" # not needed
source input.txt


This produces what you want (a value in l1 of R2):



$ cat - > input.txt <<EOF
> l1="R2"
> l2="R1"
> EOF
$ cat - > output.sh <<'EOF'
> l1="" # not needed
> l2="" # not needed
> source input.txt
> echo $l1
> EOF
$ sh output.sh
R2





share|improve this answer























  • no its not working
    – Shubham Jain
    Jul 18 at 14:08










  • @ShubhamJain in what way? what should it do? What result are you trying to achieve?
    – L. Scott Johnson
    Jul 18 at 14:33










  • after running your soultion , then also my variable value is same as before,there is no value in variable l1
    – Shubham Jain
    Jul 18 at 14:36











  • It works. I've added the shell output that shows that it produces the desired value in l1. Please describe completely what you want to do that this isn't doing or show completely what you are doing that doesn't work.
    – L. Scott Johnson
    Jul 18 at 14:51










  • Yes it worked for me also now, i was doing it wrong. tysm for help
    – Shubham Jain
    Jul 18 at 14:56










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457000%2ftake-input-from-a-variable-and-store-it-into-same-variable-but-in-a-diff-file%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










If you need to output.sh to accomplish the assignments given in input.txt, you could source the input file



So this would be the content of output.sh



l1="" # not needed
l2="" # not needed
source input.txt


This produces what you want (a value in l1 of R2):



$ cat - > input.txt <<EOF
> l1="R2"
> l2="R1"
> EOF
$ cat - > output.sh <<'EOF'
> l1="" # not needed
> l2="" # not needed
> source input.txt
> echo $l1
> EOF
$ sh output.sh
R2





share|improve this answer























  • no its not working
    – Shubham Jain
    Jul 18 at 14:08










  • @ShubhamJain in what way? what should it do? What result are you trying to achieve?
    – L. Scott Johnson
    Jul 18 at 14:33










  • after running your soultion , then also my variable value is same as before,there is no value in variable l1
    – Shubham Jain
    Jul 18 at 14:36











  • It works. I've added the shell output that shows that it produces the desired value in l1. Please describe completely what you want to do that this isn't doing or show completely what you are doing that doesn't work.
    – L. Scott Johnson
    Jul 18 at 14:51










  • Yes it worked for me also now, i was doing it wrong. tysm for help
    – Shubham Jain
    Jul 18 at 14:56














up vote
0
down vote



accepted










If you need to output.sh to accomplish the assignments given in input.txt, you could source the input file



So this would be the content of output.sh



l1="" # not needed
l2="" # not needed
source input.txt


This produces what you want (a value in l1 of R2):



$ cat - > input.txt <<EOF
> l1="R2"
> l2="R1"
> EOF
$ cat - > output.sh <<'EOF'
> l1="" # not needed
> l2="" # not needed
> source input.txt
> echo $l1
> EOF
$ sh output.sh
R2





share|improve this answer























  • no its not working
    – Shubham Jain
    Jul 18 at 14:08










  • @ShubhamJain in what way? what should it do? What result are you trying to achieve?
    – L. Scott Johnson
    Jul 18 at 14:33










  • after running your soultion , then also my variable value is same as before,there is no value in variable l1
    – Shubham Jain
    Jul 18 at 14:36











  • It works. I've added the shell output that shows that it produces the desired value in l1. Please describe completely what you want to do that this isn't doing or show completely what you are doing that doesn't work.
    – L. Scott Johnson
    Jul 18 at 14:51










  • Yes it worked for me also now, i was doing it wrong. tysm for help
    – Shubham Jain
    Jul 18 at 14:56












up vote
0
down vote



accepted







up vote
0
down vote



accepted






If you need to output.sh to accomplish the assignments given in input.txt, you could source the input file



So this would be the content of output.sh



l1="" # not needed
l2="" # not needed
source input.txt


This produces what you want (a value in l1 of R2):



$ cat - > input.txt <<EOF
> l1="R2"
> l2="R1"
> EOF
$ cat - > output.sh <<'EOF'
> l1="" # not needed
> l2="" # not needed
> source input.txt
> echo $l1
> EOF
$ sh output.sh
R2





share|improve this answer















If you need to output.sh to accomplish the assignments given in input.txt, you could source the input file



So this would be the content of output.sh



l1="" # not needed
l2="" # not needed
source input.txt


This produces what you want (a value in l1 of R2):



$ cat - > input.txt <<EOF
> l1="R2"
> l2="R1"
> EOF
$ cat - > output.sh <<'EOF'
> l1="" # not needed
> l2="" # not needed
> source input.txt
> echo $l1
> EOF
$ sh output.sh
R2






share|improve this answer















share|improve this answer



share|improve this answer








edited Jul 18 at 14:50


























answered Jul 18 at 14:01









L. Scott Johnson

1182




1182











  • no its not working
    – Shubham Jain
    Jul 18 at 14:08










  • @ShubhamJain in what way? what should it do? What result are you trying to achieve?
    – L. Scott Johnson
    Jul 18 at 14:33










  • after running your soultion , then also my variable value is same as before,there is no value in variable l1
    – Shubham Jain
    Jul 18 at 14:36











  • It works. I've added the shell output that shows that it produces the desired value in l1. Please describe completely what you want to do that this isn't doing or show completely what you are doing that doesn't work.
    – L. Scott Johnson
    Jul 18 at 14:51










  • Yes it worked for me also now, i was doing it wrong. tysm for help
    – Shubham Jain
    Jul 18 at 14:56
















  • no its not working
    – Shubham Jain
    Jul 18 at 14:08










  • @ShubhamJain in what way? what should it do? What result are you trying to achieve?
    – L. Scott Johnson
    Jul 18 at 14:33










  • after running your soultion , then also my variable value is same as before,there is no value in variable l1
    – Shubham Jain
    Jul 18 at 14:36











  • It works. I've added the shell output that shows that it produces the desired value in l1. Please describe completely what you want to do that this isn't doing or show completely what you are doing that doesn't work.
    – L. Scott Johnson
    Jul 18 at 14:51










  • Yes it worked for me also now, i was doing it wrong. tysm for help
    – Shubham Jain
    Jul 18 at 14:56















no its not working
– Shubham Jain
Jul 18 at 14:08




no its not working
– Shubham Jain
Jul 18 at 14:08












@ShubhamJain in what way? what should it do? What result are you trying to achieve?
– L. Scott Johnson
Jul 18 at 14:33




@ShubhamJain in what way? what should it do? What result are you trying to achieve?
– L. Scott Johnson
Jul 18 at 14:33












after running your soultion , then also my variable value is same as before,there is no value in variable l1
– Shubham Jain
Jul 18 at 14:36





after running your soultion , then also my variable value is same as before,there is no value in variable l1
– Shubham Jain
Jul 18 at 14:36













It works. I've added the shell output that shows that it produces the desired value in l1. Please describe completely what you want to do that this isn't doing or show completely what you are doing that doesn't work.
– L. Scott Johnson
Jul 18 at 14:51




It works. I've added the shell output that shows that it produces the desired value in l1. Please describe completely what you want to do that this isn't doing or show completely what you are doing that doesn't work.
– L. Scott Johnson
Jul 18 at 14:51












Yes it worked for me also now, i was doing it wrong. tysm for help
– Shubham Jain
Jul 18 at 14:56




Yes it worked for me also now, i was doing it wrong. tysm for help
– Shubham Jain
Jul 18 at 14:56












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457000%2ftake-input-from-a-variable-and-store-it-into-same-variable-but-in-a-diff-file%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay