Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

285
Views
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 answers
Answer question

0

Make it in-line sed:

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

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!