Reputation: 2500
After my grep, I generated a file which has data as key and count but on separate lines:
$Value, "Some", $233kS
:2343
$AnotherCount, JunkValue
:38585
YetAnother, Nothing
:38484
I want a file like:
$Value, "Some", $233kS:2343
$AnotherCount, JunkValue:38585
YetAnother, Nothing:38484
The count pattern is fixed, it is always of form :[0-9]*
Is it possible using sed
or any single line command?
I looked at replace line but I want only when the count pattern is not matched.
I am interested in solution that can work for extended problem:
$Value, "Some", $233kS
$AnotherCount, JunkValue
:38585
YetAnother, Nothing
:38484
Should output:
$Value, "Some", $233kS$AnotherCount, JunkValue:38585
YetAnother, Nothing:38484
Basically, all the lines not matching the pattern should not have end line char.
Upvotes: 0
Views: 66
Reputation: 26471
Any of these might help you out:
$ awk '!(FNR%2){ print b $0 }{b=$0}' file
$ paste -sd "\0\n" file
Both of these lines assume that the odd lines need to be concatenated with the even lines
note: according to POSIX paste
"\0" is considered an empty string, not the <null>-character
Upvotes: 2