Thanks a lot!
How can I add a string after each block ?
I tried sed -ne '/debut_sect/,/fin_sect/{/debut_sect\|fin_sect/d;p}' -ne '$a\\n---- END OF BLOCK ------\n' infile
But it add ---- END OF BLOCK ------ only one time, at the end of the file !
The more complicated you make it, the tougher it gets to do it in sed, which doesn't have things programmers want like variables and conditional statements. awk does, though.
awk '
# If we get a line containing fin_sect, and P is nonzero,
# print --- END OF BLOCK ---, and set P=0.
# We have this before the P statement, so that this runs
# first, preventing fin_sect itself from being printed.
P && /fin_sect/ { print "--- END OF BLOCK ---" ; P=0 }
# Print only when variable P set to nonzero value.
P
# If we get a line containing debut_sect, set P=1.
/debut_sect/ { P=1 }' infile
TT0000013668528|ECBANYBANYB001|Jul2520121:00PM|MADHYAPRADESH|Bayan|IDEA|BHOPAL|9827936667|9302306262|9826470885TT0000013668528|ECBANYBANYB001|Jul2520121:00PM|MADHYAPRADESH|Bayan|AIRTEL|BHOPAL|9827936667|9302306262|9893124891
I have a input file as shown above.
Kindlu suggest me a query which will print repeated values once with non repeated values