Wednesday, January 6, 2021

sed tricks

 1. According to http://sed.sourceforge.net/sedfaq5.html#s5.10 you cannot directly process the EOL symbol (\n) using simple sed commands. You should read next line into the processing buffer and only AFTER THAT make necessary actions. For example, to change EOL to comma, use the following :

grep some_info filename_containing_info | awk '{print $6}' | sed ":a;N;s/\n/\,/;ta"

No comments:

Post a Comment