I have this command that deletes from one position to the end of the file, but how do I delete this position to the beginning of the file?
sed -i '/Enviar mailBlogThis/,$d' *.txt
I have this command that deletes from one position to the end of the file, but how do I delete this position to the beginning of the file?
sed -i '/Enviar mailBlogThis/,$d' *.txt
Just use sed -i '1,/destino/d' *.txt
Explanation:
sed -i '1,/Enviar mailBlogThis/d' arquivo.txt
└┬┘└┬┘ └────────┬────────┘└┬┘ └────┬────┘
│ │ │ │ └─ Arquivo(s)
│ │ │ └───────── Deleta as linhas encontradas via RegEx
│ │ └──────────────────── Limite para remoção
│ └──────────────────────────────── Começa deletar da primeira linhas
└─────────────────────────────────── Altera o arquivo
file.txt
1
2
3
4
5
Enviar mailBlogThis
6
7
8
9
0
Output:
6
7
8
9
0