* 印不出來的時候用 \x 代替
" = \x22
' = \x27
\t = \x9
* 在 sed 要換 delimiters 的時候前面要加一個 \
# do this (ugly)...
sed '/\/a\/b\/c\//{do something;}'
# ...or these (better)
sed '\#/a/b/c/#{do something;}'
sed '\_/a/b/c/_{do something;}'
sed '\%/a/b/c/%{do something;}'
# etc.
http://backreference.org/2010/02/20/using-different-delimiters-in-sed/
* grep 可以用 -H 印出檔名
* sed 要印 兩個 tab 的時候用 \\x9\x9 ,丟到 awk 裡面的話 前面各再加一個 \
* sed 真的要跑的時候加上 -i.bak -e 'SCRIPT' 就會真的改
* sed '/PATT/aNEW' 代表在 MATCH 到 PATT 這個 pattern 的後面一行加上 NEW
*sed 把換行符號拿掉
sed ':a;N;$!ba;s/\n/ /g' file
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' file
https://stackoverflow.com/questions/1251999/how-can-i-replace-a-newline-n-using-sed
- Create a label via
:a. - Append the current and next line to the pattern space via
N. - If we are before the last line, branch to the created label
$!ba($!means not to do it on the last line as there should be one final newline). - Finally the substitution replaces every newline with a space on the pattern space (which is the whole file).