grep the line contains only the match
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have the below file for example,
Hello world cheers
Hello world
Hi Hello world
Hi Hello world, How are you?
I would like to grep the line which contains only the Hello world
with the line number.
grep
add a comment |Â
up vote
0
down vote
favorite
I have the below file for example,
Hello world cheers
Hello world
Hi Hello world
Hi Hello world, How are you?
I would like to grep the line which contains only the Hello world
with the line number.
grep
1
How will you be using the line number later? If you are going to extract or change the line by its line number, then it's better to do so in one go instead of calling two utilities in sequence (getting the line number, then do something with that line).
â Kusalananda
Aug 18 at 20:30
@Kusalananda .. Thanks...as of now, i have requirement only to log these details.
â fini r
Aug 18 at 20:49
1
stackoverflow.com/questions/4709912/â¦
â Julien Lopez
Aug 18 at 22:13
Possible duplicate of grep to fetch whole line
â roaima
Aug 20 at 16:56
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have the below file for example,
Hello world cheers
Hello world
Hi Hello world
Hi Hello world, How are you?
I would like to grep the line which contains only the Hello world
with the line number.
grep
I have the below file for example,
Hello world cheers
Hello world
Hi Hello world
Hi Hello world, How are you?
I would like to grep the line which contains only the Hello world
with the line number.
grep
edited Aug 18 at 19:04
SivaPrasath
1
1
asked Aug 18 at 19:03
fini r
124
124
1
How will you be using the line number later? If you are going to extract or change the line by its line number, then it's better to do so in one go instead of calling two utilities in sequence (getting the line number, then do something with that line).
â Kusalananda
Aug 18 at 20:30
@Kusalananda .. Thanks...as of now, i have requirement only to log these details.
â fini r
Aug 18 at 20:49
1
stackoverflow.com/questions/4709912/â¦
â Julien Lopez
Aug 18 at 22:13
Possible duplicate of grep to fetch whole line
â roaima
Aug 20 at 16:56
add a comment |Â
1
How will you be using the line number later? If you are going to extract or change the line by its line number, then it's better to do so in one go instead of calling two utilities in sequence (getting the line number, then do something with that line).
â Kusalananda
Aug 18 at 20:30
@Kusalananda .. Thanks...as of now, i have requirement only to log these details.
â fini r
Aug 18 at 20:49
1
stackoverflow.com/questions/4709912/â¦
â Julien Lopez
Aug 18 at 22:13
Possible duplicate of grep to fetch whole line
â roaima
Aug 20 at 16:56
1
1
How will you be using the line number later? If you are going to extract or change the line by its line number, then it's better to do so in one go instead of calling two utilities in sequence (getting the line number, then do something with that line).
â Kusalananda
Aug 18 at 20:30
How will you be using the line number later? If you are going to extract or change the line by its line number, then it's better to do so in one go instead of calling two utilities in sequence (getting the line number, then do something with that line).
â Kusalananda
Aug 18 at 20:30
@Kusalananda .. Thanks...as of now, i have requirement only to log these details.
â fini r
Aug 18 at 20:49
@Kusalananda .. Thanks...as of now, i have requirement only to log these details.
â fini r
Aug 18 at 20:49
1
1
stackoverflow.com/questions/4709912/â¦
â Julien Lopez
Aug 18 at 22:13
stackoverflow.com/questions/4709912/â¦
â Julien Lopez
Aug 18 at 22:13
Possible duplicate of grep to fetch whole line
â roaima
Aug 20 at 16:56
Possible duplicate of grep to fetch whole line
â roaima
Aug 20 at 16:56
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
10
down vote
accepted
Try this,
grep -nx "Hello world" fileName
-n
will print the line number-x
Select only those matches that exactly match the whole line
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
10
down vote
accepted
Try this,
grep -nx "Hello world" fileName
-n
will print the line number-x
Select only those matches that exactly match the whole line
add a comment |Â
up vote
10
down vote
accepted
Try this,
grep -nx "Hello world" fileName
-n
will print the line number-x
Select only those matches that exactly match the whole line
add a comment |Â
up vote
10
down vote
accepted
up vote
10
down vote
accepted
Try this,
grep -nx "Hello world" fileName
-n
will print the line number-x
Select only those matches that exactly match the whole line
Try this,
grep -nx "Hello world" fileName
-n
will print the line number-x
Select only those matches that exactly match the whole line
answered Aug 18 at 19:06
SivaPrasath
1
1
add a comment |Â
add a comment |Â
Â
draft saved
draft discarded
Â
draft saved
draft discarded
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%2f463396%2fgrep-the-line-contains-only-the-match%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
How will you be using the line number later? If you are going to extract or change the line by its line number, then it's better to do so in one go instead of calling two utilities in sequence (getting the line number, then do something with that line).
â Kusalananda
Aug 18 at 20:30
@Kusalananda .. Thanks...as of now, i have requirement only to log these details.
â fini r
Aug 18 at 20:49
1
stackoverflow.com/questions/4709912/â¦
â Julien Lopez
Aug 18 at 22:13
Possible duplicate of grep to fetch whole line
â roaima
Aug 20 at 16:56