0
I have this command that erases from a position until the end of the file, but how to delete from this position to the beginning of the file?
sed -i '/Enviar mailBlogThis/,$d' *.txt
0
I have this command that erases from a position until the end of the file, but how to delete from this position to the beginning of the file?
sed -i '/Enviar mailBlogThis/,$d' *.txt
1
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
txt file.
1
2
3
4
5
Enviar mailBlogThis
6
7
8
9
0
Exit:
6
7
8
9
0
Browser other questions tagged sed
You are not signed in. Login or sign up in order to post.
A problem has occurred, if the file does not have the term (destination) it erases everything from the file
– Miguel Silva
You can use the
grep
, for example:grep "Enviar mailBlogThis" file.txt && sed -i '1,/Enviar mailBlogThis/d' file.txt
– Valdeir Psr
Now it worked perfectly, thank you @Valdeir
– Miguel Silva