4

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

I can see a 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

questionto42
  • 7,175
  • 4
  • 57
  • 90
peshu
  • 69
  • 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
  • 3,186
  • 4
  • 13
  • 27
  • 3
    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