how to remove double strings with sed grep awk
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
hello how to remove and clear output ?
test.txt
http://urlcom/longStringxyzABC**|**http://urlcom/longStringxyzABC
i want, |
including character deletion after
i want result
http://urlcom/longStringxyzABC
thanks
awk sed grep
add a comment |Â
up vote
0
down vote
favorite
hello how to remove and clear output ?
test.txt
http://urlcom/longStringxyzABC**|**http://urlcom/longStringxyzABC
i want, |
including character deletion after
i want result
http://urlcom/longStringxyzABC
thanks
awk sed grep
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
hello how to remove and clear output ?
test.txt
http://urlcom/longStringxyzABC**|**http://urlcom/longStringxyzABC
i want, |
including character deletion after
i want result
http://urlcom/longStringxyzABC
thanks
awk sed grep
hello how to remove and clear output ?
test.txt
http://urlcom/longStringxyzABC**|**http://urlcom/longStringxyzABC
i want, |
including character deletion after
i want result
http://urlcom/longStringxyzABC
thanks
awk sed grep
edited Jun 26 at 7:22
Arushix
9968
9968
asked Jun 25 at 22:44
tioma
32
32
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
sed 's/|.*//' test.txt
grep -oP '.*?(?=|)' test.txt
awk -F'|' 'print $1' test.txt
grep -o
outputs both (in general all) matches, which is not desired here.
â dave_thompson_085
Jun 26 at 1:58
@dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
â steeldriver
Jun 26 at 2:09
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
sed 's/|.*//' test.txt
grep -oP '.*?(?=|)' test.txt
awk -F'|' 'print $1' test.txt
grep -o
outputs both (in general all) matches, which is not desired here.
â dave_thompson_085
Jun 26 at 1:58
@dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
â steeldriver
Jun 26 at 2:09
add a comment |Â
up vote
2
down vote
accepted
sed 's/|.*//' test.txt
grep -oP '.*?(?=|)' test.txt
awk -F'|' 'print $1' test.txt
grep -o
outputs both (in general all) matches, which is not desired here.
â dave_thompson_085
Jun 26 at 1:58
@dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
â steeldriver
Jun 26 at 2:09
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
sed 's/|.*//' test.txt
grep -oP '.*?(?=|)' test.txt
awk -F'|' 'print $1' test.txt
sed 's/|.*//' test.txt
grep -oP '.*?(?=|)' test.txt
awk -F'|' 'print $1' test.txt
edited Jun 26 at 2:08
answered Jun 25 at 22:53
steeldriver
30.9k34877
30.9k34877
grep -o
outputs both (in general all) matches, which is not desired here.
â dave_thompson_085
Jun 26 at 1:58
@dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
â steeldriver
Jun 26 at 2:09
add a comment |Â
grep -o
outputs both (in general all) matches, which is not desired here.
â dave_thompson_085
Jun 26 at 1:58
@dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
â steeldriver
Jun 26 at 2:09
grep -o
outputs both (in general all) matches, which is not desired here.â dave_thompson_085
Jun 26 at 1:58
grep -o
outputs both (in general all) matches, which is not desired here.â dave_thompson_085
Jun 26 at 1:58
@dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
â steeldriver
Jun 26 at 2:09
@dave_thompson_085 oops good catch, I've amended using PCRE but please feel free to suggest a better alternative
â steeldriver
Jun 26 at 2:09
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%2f451873%2fhow-to-remove-double-strings-with-sed-grep-awk%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