linux sed
sed '1,/2021-03-23/d' mysql-error.log # print all after match
sed -n '1,/2021-03-23/p' mysql-error.log # print all before match
starting=$(sed -n '{/^DROP TABLE IF EXISTS `notify_base_info`;/{=;q}}' prd_ens-82143_20210903.dmp)
ending=$(sed -n $(($starting+1))',${/^DROP TABLE IF EXISTS/{=;q}}' prd_ens-82143_20210903.dmp)
ending=$((ending-1))
#Replace
sed 's/old/new/g' test.txt
#Print until a certain line is met sed '/begin api/q' #Print until a certain line is met, but not that line sed '/^# begin/,$d' #Print everything after a given line,Print after a given line is found. sed -n '/end api/,$p'
#Match multi pattern
sed -ne '/one\|two\|three/p' book.txt
#Print everything except matching sed -n '/regex/d;' Print everything except lines matching regex. Useful for printing files with comments.
action
a:append c:replace d:delete i:insert
p:print s: string replace q:quit e:execute