Replacing just the first occurence of a character in a line
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
I have a line with thousands of lines like this:
"100K";"0.00001";"10";"0.01"]
"101K";"0.0001";"100";"0.1"]
"102K";"1";"1000";"1"]
"102K";"1";"1000";"1"]
"103K";"0.01";"10000";"10"]
"104K";"0.1";"100000";"100"]
"105K";"1";"1000000";"1000"]
"109K";"0.000001";"1";"1"]
"120K";"0.000012";"12";"12"]
I want to replace the first occurrence of ;
in a line with :[
Making these lines equal to
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
how do I do that with sed or other unix command?
text-processing awk sed
add a comment |Â
up vote
4
down vote
favorite
I have a line with thousands of lines like this:
"100K";"0.00001";"10";"0.01"]
"101K";"0.0001";"100";"0.1"]
"102K";"1";"1000";"1"]
"102K";"1";"1000";"1"]
"103K";"0.01";"10000";"10"]
"104K";"0.1";"100000";"100"]
"105K";"1";"1000000";"1000"]
"109K";"0.000001";"1";"1"]
"120K";"0.000012";"12";"12"]
I want to replace the first occurrence of ;
in a line with :[
Making these lines equal to
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
how do I do that with sed or other unix command?
text-processing awk sed
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I have a line with thousands of lines like this:
"100K";"0.00001";"10";"0.01"]
"101K";"0.0001";"100";"0.1"]
"102K";"1";"1000";"1"]
"102K";"1";"1000";"1"]
"103K";"0.01";"10000";"10"]
"104K";"0.1";"100000";"100"]
"105K";"1";"1000000";"1000"]
"109K";"0.000001";"1";"1"]
"120K";"0.000012";"12";"12"]
I want to replace the first occurrence of ;
in a line with :[
Making these lines equal to
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
how do I do that with sed or other unix command?
text-processing awk sed
I have a line with thousands of lines like this:
"100K";"0.00001";"10";"0.01"]
"101K";"0.0001";"100";"0.1"]
"102K";"1";"1000";"1"]
"102K";"1";"1000";"1"]
"103K";"0.01";"10000";"10"]
"104K";"0.1";"100000";"100"]
"105K";"1";"1000000";"1000"]
"109K";"0.000001";"1";"1"]
"120K";"0.000012";"12";"12"]
I want to replace the first occurrence of ;
in a line with :[
Making these lines equal to
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
how do I do that with sed or other unix command?
text-processing awk sed
text-processing awk sed
edited 4 hours ago
David Foerster
948616
948616
asked 9 hours ago
SpaceDog
1,658122851
1,658122851
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
11
down vote
accepted
sed 's/;/:[/' file
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
1
if you add-i
, you do it in one go.
â Rui F Ribeiro
9 hours ago
add a comment |Â
up vote
1
down vote
Since you tagged the question with awk:
awk ' sub(/;/, ":["); print; '
add a comment |Â
up vote
0
down vote
You can try with below 2 commands also:
perl -pne "s/;/:[/" filename
sed 's/;/:[/1' filename
Output:
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
11
down vote
accepted
sed 's/;/:[/' file
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
1
if you add-i
, you do it in one go.
â Rui F Ribeiro
9 hours ago
add a comment |Â
up vote
11
down vote
accepted
sed 's/;/:[/' file
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
1
if you add-i
, you do it in one go.
â Rui F Ribeiro
9 hours ago
add a comment |Â
up vote
11
down vote
accepted
up vote
11
down vote
accepted
sed 's/;/:[/' file
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
sed 's/;/:[/' file
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
answered 9 hours ago
Goro
8,14153878
8,14153878
1
if you add-i
, you do it in one go.
â Rui F Ribeiro
9 hours ago
add a comment |Â
1
if you add-i
, you do it in one go.
â Rui F Ribeiro
9 hours ago
1
1
if you add
-i
, you do it in one go.â Rui F Ribeiro
9 hours ago
if you add
-i
, you do it in one go.â Rui F Ribeiro
9 hours ago
add a comment |Â
up vote
1
down vote
Since you tagged the question with awk:
awk ' sub(/;/, ":["); print; '
add a comment |Â
up vote
1
down vote
Since you tagged the question with awk:
awk ' sub(/;/, ":["); print; '
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Since you tagged the question with awk:
awk ' sub(/;/, ":["); print; '
Since you tagged the question with awk:
awk ' sub(/;/, ":["); print; '
answered 6 hours ago
David Foerster
948616
948616
add a comment |Â
add a comment |Â
up vote
0
down vote
You can try with below 2 commands also:
perl -pne "s/;/:[/" filename
sed 's/;/:[/1' filename
Output:
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
add a comment |Â
up vote
0
down vote
You can try with below 2 commands also:
perl -pne "s/;/:[/" filename
sed 's/;/:[/1' filename
Output:
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You can try with below 2 commands also:
perl -pne "s/;/:[/" filename
sed 's/;/:[/1' filename
Output:
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
You can try with below 2 commands also:
perl -pne "s/;/:[/" filename
sed 's/;/:[/1' filename
Output:
"100K":["0.00001";"10";"0.01"]
"101K":["0.0001";"100";"0.1"]
"102K":["1";"1000";"1"]
"102K":["1";"1000";"1"]
"103K":["0.01";"10000";"10"]
"104K":["0.1";"100000";"100"]
"105K":["1";"1000000";"1000"]
"109K":["0.000001";"1";"1"]
"120K":["0.000012";"12";"12"]
edited 5 hours ago
David Foerster
948616
948616
answered 7 hours ago
Praveen Kumar BS
1,030128
1,030128
add a comment |Â
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%2f474287%2freplacing-just-the-first-occurence-of-a-character-in-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