I have a file with little blocks beginning with a number 761XXXXXX, and 0, 1, 2 or 3 lines below of it beginning with STUS as follow:
761625820
STUS ACTIVE 16778294
STUS NOT ACTIVE
761157389
STUS ACTIVE 16778294
761554921
STUS ACTIVE 16778294
STUS NOT ACTIVE
STUS ACTIVE OP
761229934
761335544
STUS ACTIVE 16778294
I was trying to join the blocks in a single line as follow desired output:
761625820 STUS ACTIVE 16778294 STUS NOT ACTIVE
761157389 STUS ACTIVE 16778294
761554921 STUS ACTIVE 16778294 STUS NOT ACTIVE STUS ACTIVE OP
761229934
761335544 STUS ACTIVE 16778294
I tried with something I thinked, but doesn`t seem to work.
I have the same pb : joining 3 lines in a data file when they belong to a same sequence number :
like that :
Your suggestion seems being exactly what I try to have (for 3 hours now, I am a very beginner wth sed.. :o)
but could you please detail the explanation ?
instead of trying to match lines not starting with "761" I want lines not starting with a sequence number between parenthesis so I replaced the
sed -n '/^761/{
with
sed -n '/^\([0-9]*\)/{
but I dont succeed in understanding the rest of the code