Using grep to locate and store a line
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I've searched stackExchange and I cannot find a result so here we go.
I am attempting to use a grep command to search a file for a particular substring and if it finds that substring, I want it to store the line that contains it in the variable presented. Assuming my code is as follows
schemas="schemas.txt"
schema_name= ( 'cut -d' ' -f2 databases.txt )
line=( `grep ^$schema_name $schemas` )
echo $line
my output is people
which is the substring that $schemas_name
holds currently.
Can anyone point me in the right direction? I apologize if this question seems like it's been asked before but I can't find it anywhere.
Important Note: people
is the first word in the line that I am trying to allocate and store in the variable line
bash
New contributor
add a comment |Â
up vote
0
down vote
favorite
I've searched stackExchange and I cannot find a result so here we go.
I am attempting to use a grep command to search a file for a particular substring and if it finds that substring, I want it to store the line that contains it in the variable presented. Assuming my code is as follows
schemas="schemas.txt"
schema_name= ( 'cut -d' ' -f2 databases.txt )
line=( `grep ^$schema_name $schemas` )
echo $line
my output is people
which is the substring that $schemas_name
holds currently.
Can anyone point me in the right direction? I apologize if this question seems like it's been asked before but I can't find it anywhere.
Important Note: people
is the first word in the line that I am trying to allocate and store in the variable line
bash
New contributor
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I've searched stackExchange and I cannot find a result so here we go.
I am attempting to use a grep command to search a file for a particular substring and if it finds that substring, I want it to store the line that contains it in the variable presented. Assuming my code is as follows
schemas="schemas.txt"
schema_name= ( 'cut -d' ' -f2 databases.txt )
line=( `grep ^$schema_name $schemas` )
echo $line
my output is people
which is the substring that $schemas_name
holds currently.
Can anyone point me in the right direction? I apologize if this question seems like it's been asked before but I can't find it anywhere.
Important Note: people
is the first word in the line that I am trying to allocate and store in the variable line
bash
New contributor
I've searched stackExchange and I cannot find a result so here we go.
I am attempting to use a grep command to search a file for a particular substring and if it finds that substring, I want it to store the line that contains it in the variable presented. Assuming my code is as follows
schemas="schemas.txt"
schema_name= ( 'cut -d' ' -f2 databases.txt )
line=( `grep ^$schema_name $schemas` )
echo $line
my output is people
which is the substring that $schemas_name
holds currently.
Can anyone point me in the right direction? I apologize if this question seems like it's been asked before but I can't find it anywhere.
Important Note: people
is the first word in the line that I am trying to allocate and store in the variable line
bash
bash
New contributor
New contributor
New contributor
asked 2 mins ago
Conman
1
1
New contributor
New contributor
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Conman is a new contributor. Be nice, and check out our Code of Conduct.
Conman is a new contributor. Be nice, and check out our Code of Conduct.
Conman is a new contributor. Be nice, and check out our Code of Conduct.
Conman is a new contributor. Be nice, and check out our Code of Conduct.
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%2f476170%2fusing-grep-to-locate-and-store-a-line%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