1

I am looking for something some simple command to cut few lines from file1 and past in file2.

I can see few blogs to copy but don't see anything how to cut them. Any help would be great.

Eg: File1: Move SA & DBA lines to new file(file2)

DevOps

QA

Engineering

SA

DBA

peshu
  • 39
  • 1
  • 5

1 Answers1

0

Try this:

sed -n begin_line,end_line[p] filename > newfile && sed -i 'begin_line,end_line d' filename

From sed manual.

Related question and study:

How can I extract a predetermined range of lines from a text file on Unix?

Roberto Gonçalves
  • 2,796
  • 4
  • 12
  • 27
  • 1
    When I tried this, it is copying the lines but it is not deleting from the file1. I want to cut (remove/delete) the lines from file1 and past it in file2. – peshu Aug 04 '17 at 21:12