I'd like to merge two consecutive lines in a Windows text file using external bash environment like the one that for instance Cygwin or MobaXTerm provide.
I know there are similar questions asked and already set to solved but for some reason they don't work with my environment. Is it perhaps cos Windows is adding some invisible characters unrecognized by bash tools?
Here are the solutions from other similar questions which I already tried:
awk 'NR%2{a=$0;next}{print a","$0}' test.txt
grep "line" test.txt |awk 'NR==0{prefix=$0;next} {print prefix, $0}'
sed '$!N;s/\n/,/' test.txt
Input I'm working with:
first line
second line
third line
fourth line
fifth line
sixth line
Expected result:
first line,second line
third line,fourth line
fifth line,sixth line
Actual result with any of the code I tried so far:
1)
➤ sed '$!N;s/\n/,/' test.txt
,second line
,fourth line
,sixth line
2)
➤ grep "line" test.txt |awk 'NR==0{prefix=$0;next} {print prefix, $0}'
first line
second line
third line
fourth line
fifth line
sixth line
Any help here will be greatly appreciated.