take input from a Variable and store it into same variable but in a diff file
Clash 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
linux bash shell-script
add a comment |Â
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
linux bash shell-script
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
add a comment |Â
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
linux bash shell-script
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
linux bash shell-script
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
add a comment |Â
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
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
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
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
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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