replacing comma with numbers in a string
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I have text file contain strings like this
abc,def,ghi,jkl,mno,pqr,stu,wxyz
I want to make it like this
1.abc
2.def
3.ghi
4.jkl
5.mno
6.pqr
7.stu
8.wxyz
how can i do that using sed?
sed
New contributor
Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
2
down vote
favorite
I have text file contain strings like this
abc,def,ghi,jkl,mno,pqr,stu,wxyz
I want to make it like this
1.abc
2.def
3.ghi
4.jkl
5.mno
6.pqr
7.stu
8.wxyz
how can i do that using sed?
sed
New contributor
Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have text file contain strings like this
abc,def,ghi,jkl,mno,pqr,stu,wxyz
I want to make it like this
1.abc
2.def
3.ghi
4.jkl
5.mno
6.pqr
7.stu
8.wxyz
how can i do that using sed?
sed
New contributor
Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have text file contain strings like this
abc,def,ghi,jkl,mno,pqr,stu,wxyz
I want to make it like this
1.abc
2.def
3.ghi
4.jkl
5.mno
6.pqr
7.stu
8.wxyz
how can i do that using sed?
sed
sed
New contributor
Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 33 mins ago
Kevin
415
415
New contributor
Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
You can do this
echo abc,def,ghi,jkl,mno,pqr,stu,wxyz | sed 's/,/n/g' | nl -s "."
1.abc
2.def
3.ghi
4.jkl
5.mno
6.pqr
7.stu
8.wxyz
2
cool +1. Didn't know aboutnl
. Add-w 1
tonl
to get the desired output.
– RoVo
22 mins ago
add a comment |Â
up vote
1
down vote
You can use GNU awk
:
awk -v RS=',|n' 'printf "%s.%sn",NR,$0' <<< "abc,def,ghi,jkl,mno,pqr,stu,wxyz"
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can do this
echo abc,def,ghi,jkl,mno,pqr,stu,wxyz | sed 's/,/n/g' | nl -s "."
1.abc
2.def
3.ghi
4.jkl
5.mno
6.pqr
7.stu
8.wxyz
2
cool +1. Didn't know aboutnl
. Add-w 1
tonl
to get the desired output.
– RoVo
22 mins ago
add a comment |Â
up vote
2
down vote
accepted
You can do this
echo abc,def,ghi,jkl,mno,pqr,stu,wxyz | sed 's/,/n/g' | nl -s "."
1.abc
2.def
3.ghi
4.jkl
5.mno
6.pqr
7.stu
8.wxyz
2
cool +1. Didn't know aboutnl
. Add-w 1
tonl
to get the desired output.
– RoVo
22 mins ago
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can do this
echo abc,def,ghi,jkl,mno,pqr,stu,wxyz | sed 's/,/n/g' | nl -s "."
1.abc
2.def
3.ghi
4.jkl
5.mno
6.pqr
7.stu
8.wxyz
You can do this
echo abc,def,ghi,jkl,mno,pqr,stu,wxyz | sed 's/,/n/g' | nl -s "."
1.abc
2.def
3.ghi
4.jkl
5.mno
6.pqr
7.stu
8.wxyz
answered 30 mins ago
Goro
8,15253980
8,15253980
2
cool +1. Didn't know aboutnl
. Add-w 1
tonl
to get the desired output.
– RoVo
22 mins ago
add a comment |Â
2
cool +1. Didn't know aboutnl
. Add-w 1
tonl
to get the desired output.
– RoVo
22 mins ago
2
2
cool +1. Didn't know about
nl
. Add -w 1
to nl
to get the desired output.– RoVo
22 mins ago
cool +1. Didn't know about
nl
. Add -w 1
to nl
to get the desired output.– RoVo
22 mins ago
add a comment |Â
up vote
1
down vote
You can use GNU awk
:
awk -v RS=',|n' 'printf "%s.%sn",NR,$0' <<< "abc,def,ghi,jkl,mno,pqr,stu,wxyz"
add a comment |Â
up vote
1
down vote
You can use GNU awk
:
awk -v RS=',|n' 'printf "%s.%sn",NR,$0' <<< "abc,def,ghi,jkl,mno,pqr,stu,wxyz"
add a comment |Â
up vote
1
down vote
up vote
1
down vote
You can use GNU awk
:
awk -v RS=',|n' 'printf "%s.%sn",NR,$0' <<< "abc,def,ghi,jkl,mno,pqr,stu,wxyz"
You can use GNU awk
:
awk -v RS=',|n' 'printf "%s.%sn",NR,$0' <<< "abc,def,ghi,jkl,mno,pqr,stu,wxyz"
answered 24 mins ago
oliv
1,186210
1,186210
add a comment |Â
add a comment |Â
Kevin is a new contributor. Be nice, and check out our Code of Conduct.
Â
draft saved
draft discarded
Kevin is a new contributor. Be nice, and check out our Code of Conduct.
Kevin is a new contributor. Be nice, and check out our Code of Conduct.
Kevin is a new contributor. Be nice, and check out our Code of Conduct.
Â
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%2f474441%2freplacing-comma-with-numbers-in-a-string%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