Removing part of a string before a pattern
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
Am trying to use the sed command to remove all the text before the first numeric character in all the lines, by using the following
sed 's/.*[0-9]//' temp1.txt
However, it is removing all the text up to the last numeric character.
sed
add a comment |Â
up vote
2
down vote
favorite
Am trying to use the sed command to remove all the text before the first numeric character in all the lines, by using the following
sed 's/.*[0-9]//' temp1.txt
However, it is removing all the text up to the last numeric character.
sed
you should add sample input/output to clarify whether or not you want to remove the first digit as well... you text saysbefore
but the code you tried removes the digit
â Sundeep
Oct 28 '17 at 15:25
see also stackoverflow.com/questions/5319840/â¦
â Sundeep
Oct 28 '17 at 15:25
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Am trying to use the sed command to remove all the text before the first numeric character in all the lines, by using the following
sed 's/.*[0-9]//' temp1.txt
However, it is removing all the text up to the last numeric character.
sed
Am trying to use the sed command to remove all the text before the first numeric character in all the lines, by using the following
sed 's/.*[0-9]//' temp1.txt
However, it is removing all the text up to the last numeric character.
sed
asked Oct 28 '17 at 15:07
thefinn
112
112
you should add sample input/output to clarify whether or not you want to remove the first digit as well... you text saysbefore
but the code you tried removes the digit
â Sundeep
Oct 28 '17 at 15:25
see also stackoverflow.com/questions/5319840/â¦
â Sundeep
Oct 28 '17 at 15:25
add a comment |Â
you should add sample input/output to clarify whether or not you want to remove the first digit as well... you text saysbefore
but the code you tried removes the digit
â Sundeep
Oct 28 '17 at 15:25
see also stackoverflow.com/questions/5319840/â¦
â Sundeep
Oct 28 '17 at 15:25
you should add sample input/output to clarify whether or not you want to remove the first digit as well... you text says
before
but the code you tried removes the digitâ Sundeep
Oct 28 '17 at 15:25
you should add sample input/output to clarify whether or not you want to remove the first digit as well... you text says
before
but the code you tried removes the digitâ Sundeep
Oct 28 '17 at 15:25
see also stackoverflow.com/questions/5319840/â¦
â Sundeep
Oct 28 '17 at 15:25
see also stackoverflow.com/questions/5319840/â¦
â Sundeep
Oct 28 '17 at 15:25
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
this is due to eager algorithm of sed.
use:
sed 's/^[^0-9]*//' temp1.txt
where
^
begining of line[^0-9]
any char but 0-9*
multiple time
1
This will also remove the first numeric character, if this is not desired, leave off the second[0-9]
â crater2150
Oct 28 '17 at 15:17
@crater2150 edited, thanks.
â Archemar
Oct 28 '17 at 15:38
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
this is due to eager algorithm of sed.
use:
sed 's/^[^0-9]*//' temp1.txt
where
^
begining of line[^0-9]
any char but 0-9*
multiple time
1
This will also remove the first numeric character, if this is not desired, leave off the second[0-9]
â crater2150
Oct 28 '17 at 15:17
@crater2150 edited, thanks.
â Archemar
Oct 28 '17 at 15:38
add a comment |Â
up vote
2
down vote
this is due to eager algorithm of sed.
use:
sed 's/^[^0-9]*//' temp1.txt
where
^
begining of line[^0-9]
any char but 0-9*
multiple time
1
This will also remove the first numeric character, if this is not desired, leave off the second[0-9]
â crater2150
Oct 28 '17 at 15:17
@crater2150 edited, thanks.
â Archemar
Oct 28 '17 at 15:38
add a comment |Â
up vote
2
down vote
up vote
2
down vote
this is due to eager algorithm of sed.
use:
sed 's/^[^0-9]*//' temp1.txt
where
^
begining of line[^0-9]
any char but 0-9*
multiple time
this is due to eager algorithm of sed.
use:
sed 's/^[^0-9]*//' temp1.txt
where
^
begining of line[^0-9]
any char but 0-9*
multiple time
edited Oct 28 '17 at 15:37
answered Oct 28 '17 at 15:14
Archemar
19k93366
19k93366
1
This will also remove the first numeric character, if this is not desired, leave off the second[0-9]
â crater2150
Oct 28 '17 at 15:17
@crater2150 edited, thanks.
â Archemar
Oct 28 '17 at 15:38
add a comment |Â
1
This will also remove the first numeric character, if this is not desired, leave off the second[0-9]
â crater2150
Oct 28 '17 at 15:17
@crater2150 edited, thanks.
â Archemar
Oct 28 '17 at 15:38
1
1
This will also remove the first numeric character, if this is not desired, leave off the second
[0-9]
â crater2150
Oct 28 '17 at 15:17
This will also remove the first numeric character, if this is not desired, leave off the second
[0-9]
â crater2150
Oct 28 '17 at 15:17
@crater2150 edited, thanks.
â Archemar
Oct 28 '17 at 15:38
@crater2150 edited, thanks.
â Archemar
Oct 28 '17 at 15:38
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%2f401076%2fremoving-part-of-a-string-before-a-pattern%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
you should add sample input/output to clarify whether or not you want to remove the first digit as well... you text says
before
but the code you tried removes the digitâ Sundeep
Oct 28 '17 at 15:25
see also stackoverflow.com/questions/5319840/â¦
â Sundeep
Oct 28 '17 at 15:25