![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| unix script for loading a data from a file into database | grajesh_955 | Shell Programming and Scripting | 5 | 3 Weeks Ago 08:49 PM |
| Split large file and add header and footer to each small files | ashish4422 | Shell Programming and Scripting | 7 | 07-07-2008 11:13 AM |
| Split large file and add header and footer to each file | ashish4422 | Shell Programming and Scripting | 1 | 04-15-2008 03:12 AM |
| unix script to takes the old data from a TXT file and compress them into new file | vpandey | Shell Programming and Scripting | 2 | 03-05-2008 08:10 AM |
| Split A Large File | nbvcxzdz | Shell Programming and Scripting | 4 | 11-14-2005 05:48 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need to split a large data file using a Unix script
Greetings all:
I am still new to Unix environment and I need help with the following requirement. I have a large sequential file sorted on a field (say store#) that is being split into several smaller files, one for each store. That means if there are 500 stores, there will be 500 files. This is being done using a SQR program right now. How is this done using a Unix script? Any Pseudocode will be appreciated. In the below example, the first two records are written to a file and when there's a change in the store#, it writes to an other file. The names of the files are lgXXX where XXX is the store number (i.e, lg002, lg003 and so on). Format of the input file: Store# City ZIP -------------------- 002 XXX 01601 ..> written to lg002 file 002 YYY 01601 ..> written to lg002 file 003 AAA 11111 ..> written to lg003 file 004 BBB 11222 ..> written to lg004 file : : : 555 XYZ 99999 ..> written to lg555 file Thank you! SaiK |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
#!/bin/ksh
while read store city zip
do
echo "${store} ${city} ${zip}" >> "lg${store}"
done < myInputFile
|
||||
| Google The UNIX and Linux Forums |