Operating System - HP-UX
1833685 Members
3756 Online
110062 Solutions
New Discussion

How to divide one file to become two files

 
SOLVED
Go to solution
suryaj
Occasional Contributor

How to divide one file to become two files

I want to divide file Xx010801.SOL that has certain format to become file Header.txt and Line.txt that also have certain format.Can any one help me to resolve this problem??I have
attached all of files above.
Surya
5 REPLIES 5
Dayanand Naik
Frequent Advisor

Re: How to divide one file to become two files

Hi

I think u can use split command, where split reads file and writes it in pieces (default 1000 lines) onto a set of output files.(only ASCII letters are used, a maximum of 676 files).

use man split for more info

Hope this helps.

Regards,
Dayanand Naik
Dayanand Naik
Ravi_8
Honored Contributor

Re: How to divide one file to become two files

Hi,
the command "split"can be used, where as this command form files of 1000 lines each.each file ending with o/pfile_nameaa,o/pfile_namebb,...
since you wanted to split according to the format, then the best way is to use "awk"
never give up
Robin Wakefield
Honored Contributor

Re: How to divide one file to become two files

Hi,

Looking at your 3 files, I'd suggest either awk, although perl would probably be easier and quicker.

Rgds, Robin.
Sachin Patel
Honored Contributor

Re: How to divide one file to become two files

Hi Suryaj,
I will say use Perl.
I don't know what you are taking from one file to another one. Give me more info and I can help in perl.

Sachin
Is photography a hobby or another way to spend $
Andreas Voss
Honored Contributor
Solution

Re: How to divide one file to become two files

Hi,

put you a script at attachment.

Good luck