05-05-2010
Split the single file lines into multiple files
Let's assume that I have a file name called ‘A' and it has 100 lines in it and would like to split these 100 lines into 4 files as specified bellow.
INPUT: Input file name A
1
2
3
4
5
6
7
8
9
........100
Output: 4 output files (x,y,z,w)
File x should contains (Skip 4 lines)
1
5
9
13
17
21
............
File y should contains (skip 4 lines)
2
6
10
14
18
22
...........
File z should contains (skip 4 lines)
3
7
11
15
19
23
...................
File w should contain (skip 4 lines)
4
8
12
16
20
24
Regards
Subba
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,I have a single sql file containing many create table ddl's.Example:
CREATE TABLE sec_afs
(
rpt_per_typ_c char(1) NOT NULL,
rpt_per_typ_t varchar(20) NULL,
LOCK ALLPAGES
go
EXEC sp_primarykey 'sec_afs', rpt_per_typ_c
go
GRANT SELECT ON sec_afs TO developer_read_only... (5 Replies)
Discussion started by: smarter_aries
5 Replies
2. Shell Programming and Scripting
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
3. UNIX for Dummies Questions & Answers
Hi,
I am new to unix. we have a requirement here to split a single file into multiples files based on the number of people available for processing. So i tried my hand at writing some code as below.
#!/bin/bash
var1=`wc -l $filename`
var2=$var1/$splitno
split -l $var2 $1
Please help me... (6 Replies)
Discussion started by: quirkguy
6 Replies
4. Shell Programming and Scripting
Hi,
Input
7488 7389 chr1.fa chr1.fa
3546 9887 chr5.fa chr9.fa
7387 7898 chrX.fa chr3.fa
7488 7389 chr21.fa chr3.fa
7488 7389 chr1.fa chr1.fa
3546 9887 chr9.fa chr5.fa
7898 7387 chrX.fa chr3.fa
Desired Output
7488 7389 chr1.fa chr1.fa 2
3546 9887 chr5.fa chr9.fa 2... (2 Replies)
Discussion started by: jacobs.smith
2 Replies
5. Shell Programming and Scripting
I have one single shown below and I need to break each ST|850 & SE to separate file using unix script. Below example should create 3 files. We can use ST & SE to filter as these field names will remain same.
Please advice with the unix code.
ST|850
BEG|PO|1234
LIN|1|23
SE|4
ST|850... (3 Replies)
Discussion started by: prasadm
3 Replies
6. Shell Programming and Scripting
The following code will split the infile into multiple files. However, I need it to insert the same first 3 lines from the original input file into each splitted file. How do I modify my script below to do so:
print -n "Enter file name to split? " ; read infile
if
then
echo "Invalid file... (4 Replies)
Discussion started by: mrn6430
4 Replies
7. Shell Programming and Scripting
Hi,
i need a single command to create multiple empty files(no trailing lines as well) and empty the files if already existing.
please let me know or if this has been ansered, if some ocan share the link please, thanks
> newfile.txt
or
:> newfile.txt
do not work (4 Replies)
Discussion started by: Onkar Banerjee
4 Replies
8. UNIX for Dummies Questions & Answers
input file:
AD,00,--,---,---,---,---,---,---,--,--,---
AM,000,---,---,---,---,---,---
AR, ,---,--,---,---
AA,---,---,---,---
AT,---
AU,---,---,---
AS,---,---
AP,---,---,---
AI,---
AD,00,---,---,---, ,---,---,---,---,---,---
AM,000,---,---,---
AR,... (6 Replies)
Discussion started by: kcdg859
6 Replies
9. Shell Programming and Scripting
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
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