November 25, 2024, 12:39:48 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Please tell me about this  (Read 5033 times)

Offline vlinux1

  • Linux Learner
  • ***
  • Posts: 118
Please tell me about this
« on: August 07, 2007, 07:33:54 AM »
Hello All,

I have a simple problem I have one file that contains some data that is old file  another file is new  and i want to copy some data ( 10000 lines) from old file to new without overwriting the new file. I don't want to disturb
new file.

Please tell me ..........

Thnaks in Advance

Vj 


Offline rsw686

  • Linux Noob !
  • *
  • Posts: 4
Re: Please tell me about this
« Reply #1 on: November 30, 2007, 07:19:42 PM »
How do you plan to copy data from the old to new file without disturbing the new file data? Are you trying to append the data. If so you could use

cat oldfile >> newfile

The >> signifies to append rather than replace.

Offline gauravbajaj

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 658
Re: Please tell me about this
« Reply #2 on: December 07, 2007, 10:38:34 AM »
hi
 if you want to redirect a partial data, you can try these commands

head -1000 oldfile >> newfile

and if u want to extract data from a middle of file, you can try the ombination of head and tail or you can try below

sed '12,36!d' oldfile >> newfile

or

sed '12,36p' oldfile >> newfile

Above commands will extract the lines from 12 to 36 from oldfile and append it into new file
try both above commands  as  I am not very much sure about  which from above sed command runs , as i dont remember much , but you can give a try above

Thanks
Gaurav
« Last Edit: December 07, 2007, 10:44:36 AM by gauravbajaj »