Help with data grouping


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with data grouping
# 1  
Old 10-16-2009
Help with data grouping

Hi all,

I have a set data as shown below, and i would like to eliminate the name that no children - boy and girl. What is the appropriate command can i use(other than grep)? Please assist...

My input:
HTML Code:
name		sex	marital status		children - boy		children - girl		
~~~~		~~~	~~~~~~~~~~~~~~		~~~~~~~~~~~~~~		~~~~~~~~~~~~~~~
patrick		m	married			-			1			
alice		f	single			-			-
joanna		f	married			-			-
max		m	divorce			2			4
hendrik		m	married			1			2
lucy		f	married			-			1
albert		m	single			-			-
apple		f	divorce			-			3
june		f	married			1			-
helen		f	married			-			2
tim		m	single			-			-
wilfred		m	married			-			-
chloe		f	single			-			-
jessica		f	married			2			1
My output:
HTML Code:
name		sex	marital status		children - boy		children - girl		
~~~~		~~~	~~~~~~~~~~~~~~		~~~~~~~~~~~~~~		~~~~~~~~~~~~~~~
patrick		m	married			-			1			
max		m	divorce			2			4
hendrik		m	married			1			2
lucy		f	married			-			1
apple		f	divorce			-			3
june		f	married			1			-
helen		f	married			-			2
jessica		f	married			2			1
# 2  
Old 10-16-2009
Code:
nawk '$NF!="-"' myFile
sed '/-$/d' myFile

# 3  
Old 10-16-2009
Quote:
Originally Posted by 793589
i would like to eliminate the name that no children - boy and girl.
Code:
awk '$NF != d || $(NF-1) != d' d="-" file


Last edited by danmero; 10-17-2009 at 02:59 AM.. Reason: Fix copy/paste error ?
# 4  
Old 10-16-2009
thanks many...
could you please explain the each function that apply...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grouping and counting

Hello, I would like to group/sort a file of records by a particular field and then count how many records belong in that grouping. For example say I have the following data: 1234|"ZZZ"|"Date"|"1"|"Y"|"ABC"|""|AA ABCD|"ZZZ"|"Date"|"1"|"Y"|"ABC"|""|AA EFGH|"ZZZ"|"Date"|"1"|"Y"|"ABC"|""|BB... (14 Replies)
Discussion started by: Nik44
14 Replies

2. Shell Programming and Scripting

Yearly Grouping of Data

I need some logic that would help to group up some records that fall between two dates: Input Data COL_1 COL_2 COL_3 COL_4 COL_5 COL_6 COL_7 COL_8 COL_9 COL_10 COL_11 COL_12 C ABC ABCD 3 ZZ WLOA 2015-12-01 2015-12-15 975.73 ZZZ P 147018.64 C ABC ... (3 Replies)
Discussion started by: Ads89
3 Replies

3. Shell Programming and Scripting

Name grouping

awk 'FNR==NR {a; next} $NF in a' genes.txt refseq_exons.txt > output.txt I can not figure out how to group the same name in $4 together. Basically, all the SKI together in separate rows and all the TGFB2. Thank you :). chr1 2160133 2161174 SKI chr1 218518675 218520389 TGFB2... (1 Reply)
Discussion started by: cmccabe
1 Replies

4. Shell Programming and Scripting

Grouping

Hi all, I am using following command: perl program.pl input.txt output.txt CUTOFF 3 > groups_3.txt containing program.pl, two files (input.txt, output.txt) and getting output in groups_3.txt: But, I wish to have 30 files corresponding to each CUTOFF ranging from 0 to 30 using the same... (1 Reply)
Discussion started by: bioinfo
1 Replies

5. Shell Programming and Scripting

Selective grouping

I have a text file in this format. Group: AAA Notes: IP : 11.11.11.11 #User xxxxxxxxx #Password aaaaaaaaaaaaaaaa Group: AAA Notes: IP : 11.11.11.22 #User yyyyyyyyyyyyy #Password bbbbbbbbbbbbb (8 Replies)
Discussion started by: anil510
8 Replies

6. Shell Programming and Scripting

Help with grouping data based on range position

Input file: data_1 1000 1290 data_4 290 234 data_2 1114 1110 data_5 534 999 data_6 900 1050 . . Desired_output_file_1_0_999: data_4 290 234 data_5 534 999 Desired_output_file_2_1000_1999: data_1 1000 1290 data_2 1114 1110 (1 Reply)
Discussion started by: perl_beginner
1 Replies

7. UNIX for Advanced & Expert Users

grouping lines

Hi all, I have input lines like below: A;100;Paris;City;10;0;0 A;100;Paris;City;0;10;0 A;100;Paris;City in Europe;0;0;20 B;101;London;City;20;0;0 B;101;London;City;0;20;0 B;101;London;City in Europe;0;0;40 I need to group the above lines to: A;100;Paris;City in Europe;10;10;20... (4 Replies)
Discussion started by: andy2000
4 Replies

8. Shell Programming and Scripting

Grouping data numbers in a text file into prescribed intervals and count

I have a text file that contains numbers (listed from the smallest to the largest). For ex. 34 817 1145 1645 1759 1761 3368 3529 4311 4681 5187 5193 5199 5417 5682 . . (5 Replies)
Discussion started by: Lucky Ali
5 Replies

9. Shell Programming and Scripting

Grouping and summing data through unix

Hi everyone, I need a help on Unix scripting. I have a file is like this Date Amt 20071205 10 20071204 10 20071203 200 20071204 300 20071203 400 20071205 140 20071203 100 20071205 100... (1 Reply)
Discussion started by: pcharanraj
1 Replies

10. Shell Programming and Scripting

egrep and grouping

i am using the c shell on solaris. directories i'm working with: ls -1d DIV* DIV_dental/ DIV_ibc/ DIV_ifc/ DIV_index/ DIV_pharm/ DIV_sectionI/ DIV_sectionI-title/ DIV_sectionI-toc/ DIV_sectionII-title/ DIV_sectionII-toc/ DIV_standing/ DIV_standing-toc/ DIV_title/ DIV_vision/ (1 Reply)
Discussion started by: effigy
1 Replies
Login or Register to Ask a Question