sed
sed '1,/mail@server\.com/d' # excluding the matched line
sed '/mail@server\.com/,$!d' # including the matched line
Explicações
-
1,/mail@server\.com/d - d elete todas as linhas da linha 1 para ( , ) [email protected]
-
/mail@server\.com/,$!d - não ( ! ) d elete todas as linhas de [email protected] para ( , ) o final do arquivo ( $ ), mas todo o resto
Uso
sed '…' file > file2 # save output in file2
sed -i.bak '…' file # alter file in-place saving a backup as file.bak
sed -i '…' file # alter file in-place without backup (caution!)
awk
awk 'f;/mail@server\.com/{f=1}' # excluding the matched line
awk '/mail@server\.com/{f=1}f' # including the matched line
Explicações
-
f - variable f , as variáveis são 0 = false por padrão, awk não imprime nada se a expressão for false e apenas imprimir a linha se a expressão for true
-
/mail@server\.com/{f=1} - se [email protected] for encontrado set f=1 , portanto, renderizando a expressão inteira true da próxima vez que f ocorrer na expressão
Uso
awk '…' file > file2 # save output in file2
awk -iinplace -vINPLACE_SUFFIX=.bak '…' file # alter file in-place saving a backup as file.bak
awk -iinplace '…' file # alter file in-place without backup (caution!)