Can anyone explain me the below and please tell me why it is not accepting large number of strings.

sed ':a;s/(([^,|]+)[|,].*)\2/\1/;ta;y/,/|/;s/||/|/g' file_nm

Recommended Answers

All 2 Replies

what do you call «not accepting large number of strings»?

give us a representative input sample,
what the command outputs,
and what it should output.

My Input File:

AA|BB|CC
a@gmail.com,c@yahoo.co.in|a@gmail.com|a@gmail.com,g@gmail.com,d@gmail.com
y@gmail.com|x@yahoo.in,z@redhat.com|z@redhat.com
c@gmail.com|b@yahoo.co.in|c@uix.xo.in
c@gmail.com|b@yahoo.co.in|c@gmail.com,b@yahoo.co.in
by@gmail.com|by@gmail.com|ww@gmail.com

Out is coming after running the **sed ':a;s/(([^,|]+)[|,].*)\2/\1/;ta;y/,/|/;s/||/|/g' file_nm **

OutPut:
`

AA|BB|CC
a@gmail.com|c@yahoo.co.in||g|d
y@gmail.com|x@yahoo.in|z@redhat|
c@gmail.com|b@yahoo.co.in|c@uix.x
c@gmail.com|b@yahoo.co.in|
by@gmail.com|ww

`

Expected Output:

AA|BB|CC
a@gmail.com|c@yahoo.co.in|g@gmail.com|d@gmail.com
y@gmail.com|x@yahoo.in|z@redhat.com
c@gmail.com|b@yahoo.co.in|c@uix.xo.in
c@gmail.com|b@yahoo.co.in
by@gmail.com|ww@gmail.com
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.