Page 1 of 1

Moving part of a textfile - where to start?

Posted: Thu Sep 02, 2004 4:01 am
by Linkjames
I have a large text file (Several hundred lines) and I need to take line 21 through line 28 and copy them to line 41, shunting all the text below down to make space.

It looks like it should be obvious, but I can't for the life of me figure out how to do it. Could someone please point my dumb arse in the right direction please?

Ta - LinkJames

Posted: Thu Sep 02, 2004 5:40 am
by Grim...
Don't try and do it within the text file.
Take line 1 - 20 and put it into $first or something.
Then line 21-28 into $second
Line 29-40 into $third
Line 41 + to $forth.

Code: Select all

$file = $first.$second.$third.$second.$forth;

Posted: Thu Sep 02, 2004 5:45 am
by m3mn0n
I had something more complex in mind, but that works great too. ;)

Posted: Thu Sep 02, 2004 7:28 am
by timvw
or learn how to use sed, the streaming editor :)