How to group lines in file by two?
With awk
:
awk 'NR!=1{print x"-"$0}{x=$0}' file
NR!=1
applies on all line, except the first oneprint x"-"$0
print the values with dash betweenx=$0
setx
(for the next iteration)
With POSIX sed
:
sed '1{
h
d
}
H
x
s/\n/-/
' <file
or one-liner version:
sed -e '1{h;d' -e\} -e 'H;x;s/\n/-/' <file
paste -d- - ./infile <infile
^That would work really well, except that your input is off-by-one. So...
{ echo; cat <infile; } | paste -d- - ./infile | sed '1d;$d'
...would work, but maybe is too complicated...