Sponsored Content
Top Forums Shell Programming and Scripting Split a file into multiple files based on line numbers and first column value Post 302636391 by sarav.shan on Monday 7th of May 2012 11:05:29 AM
Old 05-07-2012
Split a file into multiple files based on line numbers and first column value

Hi All
I have one query,say i have a requirement like the below code should be
move to diffent files whose maximum lines can be of 10 lines.Say in the below example,it consist of 14 lines.
This should be moved logically using the data in the fisrt coloumn to file1 and file 2.The data of first coloum should
not be present in both files(file 1 and file2 for a value i.e in the below example 102103 should be in on file only.In the below
example 102103 has 8 lines and i cannot place all in file 1 bcos it will exceed the maximum lines of file(10) .
Input
Code:
102100|LName|Gender|Company|Branch|Bday|Salary|Age
102100|bbbb|male|cccc|dddd|19900814|15000|20|
102101|asdg|male|gggg|ksgu|19911216|||
102102|bdbm|male|kkkk|acke|19931018||23|
102102|kfjg|male|kkkc|gkgg|19921213|14000|24|
102102|bprb|male|cccc|pppp||15000|20|
102103|kfjg|male|kkkc|gkgg|19921213|14000|24|
102103|bprb|male|cccc|pppp||15000|20|
102103|kfjg|male|kkkc|gkgg|19921213|14000|24|
102103|bprb|male|cccc|pppp||15000|20|
102103|kfjg|male|kkkc|gkgg|19921213|14000|24|
102103|bprb|male|cccc|pppp||15000|20|
102103|kfjg|male|kkkc|gkgg|19921213|14000|24|
102103|bprb|male|cccc|pppp||15000|20|

Output should be like below:
File 1:
Code:
102100|LName|Gender|Company|Branch|Bday|Salary|Age
102100|bbbb|male|cccc|dddd|19900814|15000|20|
102101|asdg|male|gggg|ksgu|19911216|||
102102|bdbm|male|kkkk|acke|19931018||23|
102102|kfjg|male|kkkc|gkgg|19921213|14000|24|
102102|bprb|male|cccc|pppp||15000|20|

File 2
Code:
102103|kfjg|male|kkkc|gkgg|19921213|14000|24|
102103|bprb|male|cccc|pppp||15000|20|
102103|kfjg|male|kkkc|gkgg|19921213|14000|24|
102103|bprb|male|cccc|pppp||15000|20|
102103|kfjg|male|kkkc|gkgg|19921213|14000|24|
102103|bprb|male|cccc|pppp||15000|20|
102103|kfjg|male|kkkc|gkgg|19921213|14000|24|
102103|bprb|male|cccc|pppp||15000|20|

Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split single file into multiple files based on the number in the column

Dear All, I would like to split a file of the following format into multiple files based on the number in the 6th column (numbers 1, 2, 3...): ATOM 1 N GLY A 1 -3.198 27.537 -5.958 1.00 0.00 N ATOM 2 CA GLY A 1 -2.199 28.399 -6.617 1.00 0.00 ... (3 Replies)
Discussion started by: tomasl
3 Replies

2. Shell Programming and Scripting

Split a file into multiple files based on the input pattern

I have a file with lines something like. ...... 123_start ...... ....... 123_end .... ..... 456_start ...... ..... 456_end .... ..... 789_start .... .... 789_end (6 Replies)
Discussion started by: abinash
6 Replies

3. Shell Programming and Scripting

split XML file into multiple files based on pattern

Hello, I am using awk to split a file into multiple files using command: nawk '{ if ( $1 == "<process" ) { n=split($2, arr, "\""); file=arr } print > file }' processes.xml <process name="Process1.process"> ... (3 Replies)
Discussion started by: chiru_h
3 Replies

4. Shell Programming and Scripting

Split a file into multiple files based on field value

Hi, I've one requirement. I have to split one comma delimited file into multiple files based on one of the column values. How can I achieve this Unix Here is the sample data. In this case I have split the files based on date column(c4) Input file c1,c2,c3,c4,c5... (1 Reply)
Discussion started by: manasvi24
1 Replies

5. Shell Programming and Scripting

How to split file into multiple files using awk based on 1 field in the file?

Good day all I need some helps, say that I have data like below, each field separated by a tab DATE NAME ADDRESS 15/7/2012 LX a.b.c 15/7/2012 LX1 a.b.c 16/7/2012 AB a.b.c 16/7/2012 AB2 a.b.c 15/7/2012 LX2 a.b.c... (2 Replies)
Discussion started by: alexyyw
2 Replies

6. Shell Programming and Scripting

awk script to split file into multiple files based on many columns

So I have a space delimited file that I'd like to split into multiple files based on multiple column values. This is what my data looks like 1bc9A02 1 10 1000 FTDLNLVQALRQFLWSFRLPGEAQKIDRMMEAFAQRYCQCNNGVFQSTDTCYVLSFAIIMLNTSLHNPNVKDKPTVERFIAMNRGINDGGDLPEELLRNLYESIKNEPFKIPELEHHHHHH 1ku1A02 1 10... (9 Replies)
Discussion started by: viored
9 Replies

7. Shell Programming and Scripting

Split a big file into multiple files based on first four characters

I have a requirement to split a huge file to smaller text files based on first four characters which look like ABCD 1234 DFGH RREX : : : : : 0000 Each of these records are OF EQUAL bytes with a different internal layout based on the above first digit identifier.. Any help to start... (5 Replies)
Discussion started by: etldev
5 Replies

8. Shell Programming and Scripting

Extracting values based on line-column numbers from multiple text files

Dear All, I have to solve the following problems with multiple tab-separated text file but I don't know how. Any help would be greatly appreciated. I have access to Linux mint (but not as a professional). I have multiple tab-delimited files with the following structure: file1: 1 44 2 ... (5 Replies)
Discussion started by: Bastami
5 Replies

9. Shell Programming and Scripting

Split a single file into multiple files based on a value.

Hi All, I have the sales_data.csv file in the directory as below. SDDCCR; SOM ; MD6546474777 ;05-JAN-16 ABC ; KIRAN ; CB789 ;04-JAN-16 ABC ; RAMANA; KS566767477747 ;06-JAN-16 ABC ; KAMESH; A33535335 ;04-JAN-16 SDDCCR; DINESH; GD6674474747 ;08-JAN-16... (4 Replies)
Discussion started by: ROCK_PLSQL
4 Replies

10. UNIX for Beginners Questions & Answers

Split file into multiple files based on empty lines

I am using below code to split files based on blank lines but it does not work. awk 'BEGIN{i=0}{RS="";}{x="F"++i;}{print > x;}' Your help would be highly appreciated find attachment of sample.txt file (2 Replies)
Discussion started by: imranrasheedamu
2 Replies
Speech(3)						User Contributed Perl Documentation						 Speech(3)

NAME
Mac::Speech - Provide interface to PlainTalk (Speech Manager) SYNOPSIS
use Mac::Speech; DESCRIPTION
Access to Inside Macintosh is essential for proper use of these functions. Explanations of terms, processes and procedures are provided there. Any attempt to use these functions without guidance can cause severe errors in your machine, including corruption of data. You have been warned. Variables %Voice The %Voice hash will return the index to the first voice whose name matches the given text. Constants kTextToSpeechSynthType kTextToSpeechVoiceType kTextToSpeechVoiceFileType kTextToSpeechVoiceBundleType Speech Types. kNoEndingProsody kNoSpeechInterrupt kPreflightThenPause Synthesizer flags. kImmediate kEndOfWord kEndOfSentence Where to stop. kNeuter kMale kFemale Genders. Types VoiceDescription Voice Description Record. long length size of structure--set by application VoiceSpec voice voice synthesizer and ID info long version version number of voice Str63 name name of voice Str255 comment text information about voice short gender neuter, male, or female short age approximate age in years short script script code of text voice can process short language language code of voice output short region region code of voice output VoiceSpec Voice Specification Record. OSType creator ID of required synthesizer OSType id ID of voice on the synthesizer Functions SpeechManagerVersion CountVoices GetIndVoice INDEX GetVoiceDescription VOICE NewSpeechChannel VOICE DisposeSpeechChannel CHAN SpeakString S SpeakText CHAN, TEXT SpeakBuffer CHAN, TEXT, CONTROLFLAGS StopSpeech CHAN StopSpeechAt CHAN, WHERETOSTOP PauseSpeechAt CHAN, WHERETOPAUSE ContinueSpeech CHAN SpeechBusy SpeechBusySystemWide SetSpeechRate CHAN, RATE GetSpeechRate CHAN SetSpeechPitch CHAN, PITCH GetSpeechPitch CHAN TextToPhonemes CHAN, TEXT SpeechToFile CHAN, PATH Set speech channel CHAN to output to file PATH. AUTHOR
Written by Matthias Ulrich Neeracher <neeracher@mac.com>. Currently maintained by Chris Nandor <pudge@pobox.com>. perl v5.18.2 2017-10-06 Speech(3)
All times are GMT -4. The time now is 08:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy