![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple file needed with certain file_prefix | rauphelhunter | Shell Programming and Scripting | 6 | 05-27-2008 05:26 AM |
| Split file into multiple files depending upon first 4 digits | deepakgang | Shell Programming and Scripting | 4 | 04-09-2008 01:21 AM |
| Help needed to sort multiple columns in one file | ahjiefreak | UNIX for Dummies Questions & Answers | 1 | 12-07-2007 05:50 AM |
| Split A File Into 2 Files | dummy_needhelp | Shell Programming and Scripting | 7 | 11-04-2007 07:36 PM |
| Split a file into 2 or more files | bobo | UNIX for Dummies Questions & Answers | 4 | 01-16-2006 05:15 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Help Needed : Split one big file to multiple files
Hi friends,
I have data in flat file as following, first filed is the customer number. We have almost 50-100 customers in the system 100 ABC A123 100 BVC D234 100 BNC N324 200 CBC A122 200 AVC D294 200 HNC N324 300 GBC A173 300 FVC D234 300 DNC N344 I want to split the file and create individual file for each customer with customer number in the file name as follows, File Name : 100.<TimeStamp>.txt 100 ABC A123 100 BVC D234 100 BNC N324 File Name : 200.<TimeStamp>.txt 200 CBC A122 200 AVC D294 200 HNC N324 File Name : 300.<TimeStamp>.txt 300 GBC A173 300 FVC D234 300 DNC N344 I really apprciate if anyone can help me writing this script. |
|
||||
|
wow thanks Perderabo it worked like a charm!!! but it is creating one more extra file also i.e, whatever.txt. I dont want this file. I really appreciate ur input.
39 Mar 2 05:42 100whatever.txt 39 Mar 2 05:42 200whatever.txt 39 Mar 2 05:42 300whatever.txt 2 Mar 2 05:42 whatever.txt THanks Monica |
|
|||||
|
Quote:
awk -v timestamp=whatever 'NF {print $0 >> ($1timestamp".txt")}' data And you're supposed to replace "whatever" with your timestamp. |
|
||||
|
Thanks Perderabo, it worked really fine, i really appreciate if you can be more helpful to me
once the file r created i need to do following two things. 1) Following file are created with data. 100whatever.txt 100 ABC A123 100 BVC D234 100 BNC N324 100whatever.txt 200 CBC A122 200 AVC D294 200 HNC N324 100whatever.txt 300 GBC A173 300 FVC D234 300 DNC N344 Now I want to remove first record from all the file, should look like 100whatever.txt ABC A123 BVC D234 BNC N324 100whatever.txt CBC A122 AVC D294 HNC N324 100whatever.txt GBC A173 FVC D234 DNC N344 2) Zip all the files into one file as WHATEVER.zip THanks MOnica |
| Sponsored Links | ||
|
|