Sort by

recency

|

80 Discussions

|

  • + 0 comments

    The problem with the awk 'ORS=NR%2?";":"\n"' solution is it'll produce output that's separated by \ns which would be undesirable on a system where records are separated by \r\n, e.g. as is common in file created on Windows. awk 'ORS=NR%2?";":RS' solves that by using RS instead of "\n" in the script but then THAT would fail if the RS was the number 0 or similar. The robust, portable solution is awk '{ORS=(NR%2 ? ";" : RS)} 1' file

  • + 0 comments

    a longer solution, similar to the the use of the ternary operator:

    awk '{if (NR%2) {ORS=";"} else {ORS="\n"}} {print}'

  • + 0 comments
    awk '{print;}' | paste -d ";" - -
    
  • + 0 comments

    simply this works

    awk 'ORS=NR%2?";":RS'
    
  • + 1 comment

    try this people awk 'ORS=NR%2?";":"\n"'