awk ' { A[++r] = $0 } END { for (i = 1; i <= r; i++) { printf i == r ? A[i] : (A[i] "|") } printf "\n" } ' file