overview: https://sunjian.blog.youkuaiyun.com/article/details/82930982
grep
detailed explanation and examples: https://xie1997.blog.youkuaiyun.com/article/details/82974781
grep pattern ==> match by text or linux wildcards
grep "pattern" ==> match by regular expression with soft escape (variable, command replacement allowed)
grep 'pattern' ==> match by regular expression with hard escape (use as simple text)
for linux wildcards vs. linux (E)RE: https://blog.youkuaiyun.com/youmatterhsp/article/details/80528761
for generic ERE rules: https://blog.youkuaiyun.com/scgaliguodong123_/article/details/45363409
sed
for detailed explanation and examples: https://www.cnblogs.com/xuxiuxiu/p/6945385.html
1. sed read the file into a stream and process the file content line by line
2. sed option edit_command filename ==> "sed -p filename" will simply print the file line by line
===> all fancier manipulation of content selection and editting can be built up from here.
===> with neither output redirection nor -i option, NO sed command will edit the original file content; it will simply print the result to console.
3. (from https://sunjian.blog.youkuaiyun.com/article/details/82930982)
both
sed '#a txt' filename
sed '#a\txt' filename
work
4. 2 method for search/match and partially replace within a line:
from https://www.cnblogs.com/xuxiuxiu/p/6945385.html
One: Pipeline
Two:
change the 's' edit command to 'd' to delete lines with matched pattern.
==> unfortunately back reference cannot be parsed across '/'
e.g.
sed -i '/\(\(la\)\{2,\}\)/s/\1/hihihi/g' file // match lalala, replace lalala with hihihi
gives: invalid back reference
\(\) will group together expressions; not () (not for RE, though () should do the job for ERE. while \( matches the char '(' ).
la\{2,\} ==> laa.....
\(la\)\{2,\} ==> lala.......
awk
official doc for gawk: http://www.gnu.org/software/gawk/manual/gawk.html
intro and examples: https://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html
a mini programming language, a tool to disect the file and filter for particular patterns/info;
C-like; the most powerful of the 3 and can be cumbersome to deploy ==> use scripts to deal with complex instructions.