Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

286
Visualizações
Sed command not working as expected for delete particular line from file

I have try to use sed command for delete particular line from file but it seems not working properly in my system (CentOS release 6.3 (Final).

my file1.txt contain following data

line1
line2
line3
line4
line5

Now i try below command to delete 3rd line from the file.

$ sed '3d' file1.txt 

And output of above command is

line1
line2
line4
line5

But when i check original file then it seems nothing deleted. 3rd line is there.

So any one have idea why sed not working?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Make it in-line sed:

sed -i.bak '3d' file1.txt
over 4 years ago · Santiago Trujillo Relatório

0

To delete particular lines from a file using sed without creating a backup:

sed -i '' -e '3,6d' file1.txt

The command above will remove lines 3 up to and including 6 from file1.txt, without creating a backup

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda