do
echo $LINE
done
< d
ebug.log_key.txt
# uname -a
Linux 6cfa069b60a5 4.14.291-218.527.amzn2.x86_64 #1 SMP Fri Aug 26 09:54:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
追加: i (insert), a(append) 注意:'中の処理は一つの処理とする'
sed -e '/pattern/ a内容' #pattern行の後ろに、aで内容をappend
sed -e '/pattern/ i内容' #pattern行の先頭に、iで内容をinsert
範囲限定の削除
sed -e '/fromPattern/,/toPattern/ d' #fromPattern行(含む)~toPattern行(含む)まで、dで削除する
範囲限定の置換
sed -e '/fromPattern/,/toPattern/ s/pattern/replacement/' #fromPattern行(含む)~toPattern行(含む)まで、sでpatternにmatchする文字列をreplacementで置換する。
1. .* vs .*? :
>>> m = re.search('(?<=abc)def', 'abcdef') #?<=lookbehind match >>> m.group(0) 'def'
m = re.search(r'(?<=-)\w+', 'spam-egg') # must has - before \w+ >>> m.group(0) 'egg'