====== sed ====== ===== Replace the \n with values ===== Refer - https://blog.csdn.net/mfkjq/article/details/80377114 ==== Use test command ==== gsed ":a;N;s/\n/,/g;ta" Or gsed ":d;N;s/\n/,/g;td" It means it will jump to the tag :a or :d, if one time failed, then it will break. ==== Use branch command ==== gsed ":a;N;s/\n/,/g;ba" Or gsed ":d;N;s/\n/,/g;bd" ==== delete the redundant empty lines ==== Refer - http://kodango.com/sed-and-awk-notes-part-5 sed '/^$/{N;/^\n$/D}' E.g. Remove all the redundant empty lines in the Java source code find app/src/ -iname "*.java" -exec gsed -i '/^$/{N;/^\n$/D}' {} + ==== Combine every 3 lines into one line ==== sed 'N;N;s/\n/ /g' ==== Calculate the number ==== cat crashlist_googleplay_20181012.txt|grep -v "^$"|grep -A 2 "^in"|grep -v "-"|gsed "N;N;s/\n/ /g"|awk '{sum += $4 } END { print sum }'