I have a text file like this:abcdefgHow can I group those lines to obtain an output like this:a-bb-cc-dd-ee-ff-gI have to do this in shell (sh, csh, bash).I have found this:cat file | xargs -n2but the last element of first group does not became the first of the second.
How to group lines in file by two?
shell;text processing
With awk:awk 'NR!=1{print x-$0}{x=$0}' fileNR!=1 applies on all line, except the first oneprint x-$0 print the values with dash betweenx=$0 set x (for the next iteration)