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"
2. To print values of fields in the line (for example, username and password in postgresql command creating new user):
> grep -i password filename.sql | sed -En "s/.* user ([^ ]+).* password '([[:print:]]+)'.*/\1 \2/p"
No comments:
Post a Comment