Text formatting - joining lines

I have large file with data as below, in unix using sed or some cammand how to get output as below.

cat 1.txt

Normal data
1|AA|NN
4|BB|NNN
C|DDD|N
//Additional details
9C|12C|8N
Specific Details
12N|JIN|KK\NY1\
345\ABC1\KKK
90|ENO0|NDO
17|NO921|NCOKL

output shoud be as below

1|AA|NN
4|BB|NNN
C|DDD|N
9C|12C|8N
12N|JIN|KK\NY1\345\ABC1\KKK
90|ENO0|NDO
17|NO921|NCOKL

Kindly suggest if some one knows it..

awk '!/[Dd]etails/&&!/Normal/' 1.txt | sed '/[^a-zA-Z0-9]$/{h;N;s/\n//;}'

You could use awk:

awk '
/Normal data/||/Additional details/||/Specific Details/ {next}
join { $0=join$0; join=x}
/\\$/{ join=$0; next}
1' 1.txt

Thanks for the inputs, could you please suggest me in another way to delete the lines those are not having |, instead of mentioning like Normal data, Additional details..etc..since file is huge..need generic approach

Will this work for you?

awk '/\|/||/\\/' 1.txt | sed '/[^a-zA-Z0-9]$/{h;N;s/\n//;}'
grep '\|' $file

Never mind, I missed the record with the continued line, awk is the way to go.

Is it possible to achieve using sed, with out awk

Why not awk?

since i don't have a file , given file is just example (1.txt), am going to a particular directory there am doing cat * here more than one file present, and doing few validations with sed and grep, so i want to user in the same way.

You may find it interesting that grep and sed work the exact same way. If you give it a filename it reads it; if not, it reads from the pipe. So you can pipe into awk just as easily as using it on a file, just leave off the filename.

cat file* | grep ... | awk ...

Though I would point out that's trivially rewritten as

grep ... file* | awk ...

cat is seldom actually needed.

You could as easily replace your entire program with awk, if we knew what it was. awk is like grep and sed tied together, with variables, which lets it work in simple and powerful ways.

small change in input file 1.txt

Normal data
1|AA|NN
4|BB|NNN
C|DDD|N
//Additional details
9C|12C|8N
Specific Details
90|ENO0|NDO
17|NO921|NCOKL
AB|PK|PL,\
NOW,\
CONT,\
ACT
Ft|G |LG

i have tried with inputs and change in command as follows..

cat test.3 |grep '\|' | awk '/\|/||/\\/' | sed '/[\\]$/{h;N;s/\n//;}'

output giving as below

1|AA|NN
4|BB|NNN
C|DDD|N
9C|12C|8N
90|ENO0|NDO
17|NO921|NCOKL
AB|PK|PL,\Ft|G |LG

am expecting output as blow.

1|AA|NN
4|BB|NNN
C|DDD|N
9C|12C|8N
90|ENO0|NDO
17|NO921|NCOKL
AB|PK|PL,NOW,CONT,ACT
Ft|G|LG

Any inputs please