Grep all the columns based on a particular column


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Grep all the columns based on a particular column
# 1  
Old 08-28-2008
Grep all the columns based on a particular column

This is the data file that I have

21879, 0, 22, 58, 388
0, -1, 300, 1219172589765, 1708, 0, 200, 21891, 0, 0, 33, 309
0, -1, 300, 1219172591478, 1768, 0, 200, 22505, 0, 0, 33, 339
0, -1, 300, 1219172593251, 1738, 0, 200, 21888, 0, 1, 33, 308
0, -1, 300, 1219172594995, 633, 0, 200, 24878, 0, 0, 33, 272
0, -1, 300, 1219172595631, 568, 0, 200, 22371, 0, 0, 34, 269
0, -1, 300, 1219172596204, 569, 0, 200, 26014, 0, 2, 35, 272
0, -1, 300, 1219172596777, 517, 0, 200, 22377, 0, 0, 33, 287

I need to grep all the columns based on the third column value from the left. For example in this case I want all the columns and the rows based on the value of '300'

Could someone tell me how this can be done

Thanks
Poornima
# 2  
Old 08-28-2008
What does "all the columns and the rows based on the value of '300'" mean?

Code:
awk -F , '$3 == 300' file

... perhaps?
# 3  
Old 09-03-2008
awk -F "," '($3 == 300) {print $0}' filename
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Paste columns based on common column: multiple files

Hi all, I've multiple files. In this case 5. Space separated columns. Each file has 12 columns. Each file has 300-400K lines. I want to get the output such that if a value in column 2 is present in all the files then get all the columns of that value and print it side by side. Desired output... (15 Replies)
Discussion started by: genome
15 Replies

2. UNIX for Advanced & Expert Users

Conversion of rows to columns using awk based om column value

HI, My Input file data is dn:adcfgeneral id:13343 Name:xxxxxx Password:iutyerwuitywue wpuwt tuiytruityrutyrwtyrwp dn:cdferwjyyyy id:3875 Name:yyyy Password :hgfdsjkfhdsfkdlshf dshfkldshfdklsfh interset:uiuiufj My output should be ... (6 Replies)
Discussion started by: dineshaila
6 Replies

3. UNIX for Dummies Questions & Answers

Split 1 column into numerous columns based on patterns

Hi, I have a text file 'Item_List.txt' containing only 1 column. This column lists different products, each separated by the same generic string header "NEW PRODUCT, VERSION 1.1". After this the name of the product is given, then a delimiter string "PRODUCT FIELD", and then the name of the... (11 Replies)
Discussion started by: mmab
11 Replies

4. UNIX for Dummies Questions & Answers

Extract columns based on the first line of each column

Sorry to bother you guys again. I have a file1 with multiple columns like this:gga_miR_100 gga_miR_300 gga_miR_3500 gga_miR_4600 gga_miR_5600 gga_miR_30 gga_miR_500 kj rwg ghhh jy jyu we vf 5g 5hg h6 56h i8 45t 44r4 4bg 4r546 9lgtr (fer) 4fr f433 3feev f4 bf4 35g vfr ge 2rr ... (5 Replies)
Discussion started by: yuejian
5 Replies

5. Shell Programming and Scripting

Insert Columns before the last Column based on the Count of Delimiters

Hi, I have a requirement where in I need to insert delimiters before the last column of the total delimiters is less than a specified number. Say if the delimiters is less than 139, I need to insert 2 columns ( with blanks) before the last field awk -F 'Ç' '{ if (NF-1 < 139)} END { "Insert 2... (5 Replies)
Discussion started by: arunkesi
5 Replies

6. Shell Programming and Scripting

Please Help!!!! Awk for summing columns based on selected column value

a,b,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg,hh,ii a thru ii are digits and strings.... The awk needed....if coloumn 9 == i (coloumn 9 is string ), output the sum of x's(coloumn 22 ) in all records and sum of y's (coloumn 23 ) in all records in a file (records.txt).... (6 Replies)
Discussion started by: BrownBob
6 Replies

7. Shell Programming and Scripting

Merging columns based on one or more column in two files

I have two files. FileA.txt 30910 rs7468327 36587 rs10814410 91857 rs9408752 105797 rs1133715 146659 rs2262038 152695 rs2810979 181843 rs3008128 182129 rs3008131 192118 rs3008170 FileB.txt 30910 1.9415219673 0 36431 1.3351312477 0.0107191428 36587 1.3169171182... (2 Replies)
Discussion started by: genehunter
2 Replies

8. Shell Programming and Scripting

displaying columns based on column name

Hello, I have a huge file with many columns . I want to use the names of the columns to print columns to another file. for example file.txt COLA COLB COLC COLD 1 2 3 5 3 5 6 9 If I give name for multiple columns to the code:... (5 Replies)
Discussion started by: ryan9011
5 Replies

9. Shell Programming and Scripting

sum multiple columns based on column value

i have a file - it will be in sorted order on column 1 abc 0 1 abc 2 3 abc 3 5 def 1 7 def 0 1 -------- i'd like (awk maybe?) to get the results (any ideas)??? abc 5 9 def 1 8 (2 Replies)
Discussion started by: jjoe
2 Replies

10. Shell Programming and Scripting

Grep based on specific columns.

Hi, How can I grep a record for a value based on specific column. If I simply do a grep 'AB' FilenName.txt, I might end up getting the records returned whose part of value is 'AB'. But I want it specific to second column. cut -d'|' -f 2 FileName.txt | grep 'AB' But now it will return... (1 Reply)
Discussion started by: deepakwins
1 Replies
Login or Register to Ask a Question