Sponsored Content
Top Forums Shell Programming and Scripting How to split this txt file into small files? Post 302839913 by psychmyluo on Saturday 3rd of August 2013 04:33:24 PM
Old 08-03-2013
How to split this txt file into small files?

Dear shell experts,

I would like to spilt a txt file into small ones. However, I did not know how to program use shell. If someone could help, it is greatly appreciated!

Specifically, I supposed there is file named A.txt. The content of the file likes this:

Code:
Subject	run	condtion	ACC	time 	duration	weight
2	1	1	0	122.6 	2	1
2	1	1	0	144.8 	2	1
2	1	1	1	132.6 	2	1
2	1	1	1	182.6 	2	1
2	1	1	1	198.6 	2	1
2	1	1	1	230.6 	2	1
2	1	1	1	308.6 	2	1
2	1	1	1	368.6 	2	1
2	1	1	1	382.6 	2	1
2	1	1	1	410.6 	2	1
2	1	2	0	294.8 	2	1
2	1	2	0	394.8 	2	1
2	1	2	1	66.6 	        2	1
2	1	2	1	78.6 	        2	1
2	1	2	1	158.6 	2	1
2	1	2	1	207.1 	2	1

..........................
I want to split the last three columns into many small ones. if the fourth column, namely "ACC' is zero, I want to put them into a txt file, named "s00x_run1_condition1_ACC0". If the fourth column, namely "ACC' is one, I want to put them into a txt file, named "s00x_run1_condition1_ACC1"

For example, in the first two rows, the ACC column is zero, so I put the first and the second column into one txt file, and named "s00x_run1_condition1_ACC1", there are 50 subjects and every subject have 6 runs, and every runs have 3 conditions.

Although I can do those manually, it is a time-consuming task. Thus, if anybody could help, it will be greatly appreciated!

Thank you very much in advance!

Last edited by Don Cragun; 08-04-2013 at 02:04 AM.. Reason: Add CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

small script - get sql output & write into txt

Hi, how can I write a small script to run the following statement and output the result into check_result.txt select /*+RULE*/ tapname from typetbl where tapname like 'AA%' and rejectcode=9; Normally, I just type sql and get into SQL> (2 Replies)
Discussion started by: happyv
2 Replies

2. Shell Programming and Scripting

Split a file into 16 small files

Hi I want to split a file that has 'n' number of records into 16 small files. Can some one suggest me how to do this using Unix script? Thanks rrkk (10 Replies)
Discussion started by: rrkks
10 Replies

3. Shell Programming and Scripting

Split large file and add header and footer to each small files

I have one large file, after every 200 line i have to split the file and the add header and footer to each small file? It is possible to add different header and footer to each file? (7 Replies)
Discussion started by: ashish4422
7 Replies

4. UNIX for Dummies Questions & Answers

How to split a huge file into small pieces (per 2000 columns)?

Dear all, I have a big file:2879(rows)x400,170 (columns) like below. I 'd like to split the file into small pieces:2879(rows)x2000(columns) per file (the last small piece will be 2879x170. So far, I only know how to create one samll piece at one time. But actually I need to repeat this work... (6 Replies)
Discussion started by: forevertl
6 Replies

5. Shell Programming and Scripting

KSH script for split a txt file

I have a problem which I would like to solve by using UNIX power and inspired minds around world. Here is the problem I have a text file and it has data as follows 1X.....................1234567890123456789T1234598765XT1 (header) 1Z01............(sub HEADER) P100001............ Q1........... (4 Replies)
Discussion started by: ask.chowhan
4 Replies

6. Solaris

How to split 10GB file into small Sizes

Hi Team I have one 10 Gb log file I want to split it into say 10 of 1-1Gb file pls share ur experiences how to do this? Thanks in advance, (3 Replies)
Discussion started by: zimmyyash
3 Replies

7. Shell Programming and Scripting

Split a large array into small chunks

Hi, I need to split a large array "@sharedArray" into 10 small arrays. The arrays should be like @sharedArray1,@sharedArray2,@sharedArray3...so on.. Can anyone help me with the logic to do so :(:confused: (6 Replies)
Discussion started by: rkrish
6 Replies

8. UNIX for Dummies Questions & Answers

Split Every Line In Txt Into Separate Txt File, Named Same As The Line

Hi All Is there a way to export every line into new txt file where by the title of each txt output are same as the line ? I have this txt files containing names: Kandra Vanhooser Rhona Menefee Reynaldo Hutt Houston Rafferty Charmaine Lord Albertine Poucher Juana Maes Mitch Lobel... (2 Replies)
Discussion started by: Nexeu
2 Replies

9. UNIX for Beginners Questions & Answers

Split a txt file on the basis of line number

I have to split a file containing 100 lines to 5 files say from lines ,1-20 ,21-30 ,31-40 ,51-60 ,61-100 Here is i can do it for 2 file but how to handle it for more than 2 files awk 'NR < 21{ print >> "a"; next } {print >> "b" }' $input_file Please advidse. Thanks (4 Replies)
Discussion started by: abhaydas
4 Replies

10. UNIX for Beginners Questions & Answers

Split large file into 24 small files on one hour basis

I Have a large file with 24hrs log in the below format.i need to split the large file in to 24 small files on one hour based.i.e ex:from 09:55 to 10:55,10:55-11:55 can any one help me on this.! ... (20 Replies)
Discussion started by: Raghuram717
20 Replies
PMDANAMED(1)						       Performance Co-Pilot						      PMDANAMED(1)

NAME
pmdanamed - BIND (named) PMDA DESCRIPTION
pmdanamed is a Performance Metrics Domain Agent (PMDA) which exports metric values from the BIND DNS server. Further details on BIND can be found at http://isc.org/. INSTALLATION
If you want access to the names and values for the named performance metrics, do the following as root: # cd $PCP_PMDAS_DIR/named # ./Install If you want to undo the installation, do the following as root: # cd $PCP_PMDAS_DIR/named # ./Remove pmdanamed is launched by pmcd(1) and should never be executed directly. The Install and Remove scripts notify pmcd(1) when the agent is installed or removed. FILES
/var/named/data/named_stats.txt statistics file showing values exported from named /var/named/chroot/var/named/data/named_stats.txt chroot variant of statistics file showing values exported from named $PCP_PMDAS_DIR/named/Install installation script for the pmdanamed agent $PCP_PMDAS_DIR/named/Remove undo installation script for the pmdanamed agent $PCP_LOG_DIR/pmcd/named.log default log file for error messages from pmdanamed SEE ALSO
pmcd(1), named.conf(5), named(8). 3.8.10 Performance Co-Pilot PMDANAMED(1)
All times are GMT -4. The time now is 08:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy