sed to replace all occurrences of a left zero padded number having an embedded minus sign “-“ so that the minus sign is on the Left
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a tab delimited input file. Some numeric field values have a minus sign in the midst of the value such as 000-45.123
. I need the -
to be on left side like this instead: -00045.123
So if tab delimited input file contains: (spaces are tabs)
ABC 000-45.123 0-765.43 DEF 00-54 XYZ
then I want result to be
ABC -00045.123 -0765.43 DEF -0054 XYZ
All the number values with an embedded “-“ begin with 1 or more zeros and no other characters.
sed
New contributor
add a comment |
up vote
0
down vote
favorite
I have a tab delimited input file. Some numeric field values have a minus sign in the midst of the value such as 000-45.123
. I need the -
to be on left side like this instead: -00045.123
So if tab delimited input file contains: (spaces are tabs)
ABC 000-45.123 0-765.43 DEF 00-54 XYZ
then I want result to be
ABC -00045.123 -0765.43 DEF -0054 XYZ
All the number values with an embedded “-“ begin with 1 or more zeros and no other characters.
sed
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a tab delimited input file. Some numeric field values have a minus sign in the midst of the value such as 000-45.123
. I need the -
to be on left side like this instead: -00045.123
So if tab delimited input file contains: (spaces are tabs)
ABC 000-45.123 0-765.43 DEF 00-54 XYZ
then I want result to be
ABC -00045.123 -0765.43 DEF -0054 XYZ
All the number values with an embedded “-“ begin with 1 or more zeros and no other characters.
sed
New contributor
I have a tab delimited input file. Some numeric field values have a minus sign in the midst of the value such as 000-45.123
. I need the -
to be on left side like this instead: -00045.123
So if tab delimited input file contains: (spaces are tabs)
ABC 000-45.123 0-765.43 DEF 00-54 XYZ
then I want result to be
ABC -00045.123 -0765.43 DEF -0054 XYZ
All the number values with an embedded “-“ begin with 1 or more zeros and no other characters.
sed
sed
New contributor
New contributor
edited 1 hour ago
New contributor
asked 1 hour ago
ProductionSupport
11
11
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
With GNU sed:
sed -r 's/t([0-9]+)-/t-1/g' file
Output:
ABC -00045.123 -0765.43 DEF -0054 XYZ
See: The Stack Overflow Regular Expressions FAQ
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
With GNU sed:
sed -r 's/t([0-9]+)-/t-1/g' file
Output:
ABC -00045.123 -0765.43 DEF -0054 XYZ
See: The Stack Overflow Regular Expressions FAQ
add a comment |
up vote
1
down vote
With GNU sed:
sed -r 's/t([0-9]+)-/t-1/g' file
Output:
ABC -00045.123 -0765.43 DEF -0054 XYZ
See: The Stack Overflow Regular Expressions FAQ
add a comment |
up vote
1
down vote
up vote
1
down vote
With GNU sed:
sed -r 's/t([0-9]+)-/t-1/g' file
Output:
ABC -00045.123 -0765.43 DEF -0054 XYZ
See: The Stack Overflow Regular Expressions FAQ
With GNU sed:
sed -r 's/t([0-9]+)-/t-1/g' file
Output:
ABC -00045.123 -0765.43 DEF -0054 XYZ
See: The Stack Overflow Regular Expressions FAQ
answered 47 mins ago
Cyrus
7,1412835
7,1412835
add a comment |
add a comment |
ProductionSupport is a new contributor. Be nice, and check out our Code of Conduct.
ProductionSupport is a new contributor. Be nice, and check out our Code of Conduct.
ProductionSupport is a new contributor. Be nice, and check out our Code of Conduct.
ProductionSupport 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%2f480905%2fsed-to-replace-all-occurrences-of-a-left-zero-padded-number-having-an-embedded-m%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