Sponsored Content
Top Forums UNIX for Dummies Questions & Answers grep only from a range of columns Post 302632691 by torchij on Monday 30th of April 2012 02:14:40 PM
Old 04-30-2012
Unfortunately I can't really show the data, it has patient information Smilie. To be exact, I have 83 columns/fields and 32,224 rows/lines of data - comma seperated delimiter. I'm interested in the regex /hom/, but only as it appears in fields 43-83.

for example, a few lines will look like this:

PHP Code:
col    1 42     col 43      to       83
patient data      
- - - - - hom - - - - -
patient data      - - - - - - - - - - - -  
patient data      - - hom - - - - - - - -
hom ....data      - - - - - - - - - - - - 
And I don't want to return the last line, which contains a "hom" in col 1 - 42

The code I used:
PHP Code:
awk -F"," '{ M=0; for(N=43; (!M) && (N<=83); N++) if($N ~ /hom/) M++; } M' input.csv >hom.csv 
This code works, but my output file hom.csv only has 34 lines returned. By visual inspection, this is only the first 34 instances of "hom" in columns 43-83. I know by looking at my file that in line 23743, there is a "hom".

Any reason why this may be happening? Or will you have to see the entire file?

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

displaying range of columns

can i display range of columns in AWk... say in cut command i can display columnm 2-13.... is there is any simmilar command in awk (1 Reply)
Discussion started by: mahabunta
1 Replies

2. UNIX for Dummies Questions & Answers

How to match 2 columns where one column has data as a range

Hi, I have a query about joining files using data ranges. Example files below - I want to join file1 to file2 with matches where file1 column 1 is equal to file2 column1, and file1 column 2 is within the range of file2 columns 3 and 4. I would like rows which don't match to be printed too. ... (4 Replies)
Discussion started by: auburn
4 Replies

3. Shell Programming and Scripting

awk to match a numeric range specified by two columns

Hi Everyone, Here's a snippet of my data: File 1 = testRef2: A1BG - 13208 13284 AAA1 - 34758475 34873943 AAAS - 53701240 53715412File 2 = 42MLN.3.bedS2: 13208 13208 13360 13363 13484 13518 13518My awk script: awk 'NR == FNR{a=$1;next} {$1>=a}{$1<=a}{print... (5 Replies)
Discussion started by: heecha
5 Replies

4. Shell Programming and Scripting

Select columns from a matrix given within a range in BASH

I have a huge matrix file which looks like this (example matrix): 1 2 3 5 4 5 6 7 7 6 8 9 1 2 4 2 7 6 5 1 3 2 1 9 As one can see, this matrix has 4 columns and 6 rows. But my original matrix has some 3 million rows and 6000 columns. For example, on this matrix I can define my task as... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

5. UNIX for Dummies Questions & Answers

How to match 2 columns where one column has data as a range - extended

Dear all, there is a nice solution for a text merge where the second file has only variables with a numeric range ( sorry, cannot post URL + thread is closed ). The real world is however more complicated than in the earlier example. file1 A 1 A 2 A 3 B 1 B 2 B 3 B 4 C 1 C 2 C 3 C... (4 Replies)
Discussion started by: underscore
4 Replies

6. UNIX Desktop Questions & Answers

grep a range of text

hey, i need to grep / awk a list of "DEV ID" range for example for greping 0936 - 09C1 from this file: 0x5000097310036d05 558 1 20531 LOCAL GLOBAL 42048000 YES 0x8e36c8bd07ce9e13 DEV ID: 0933 0x5000097310036d05 559 1 20531 ... (1 Reply)
Discussion started by: boaz733
1 Replies

7. Shell Programming and Scripting

Grep ip range

I want to find all files under /var directory that refer to any ip from 10.1.1.1 to 10.1.1.255 using grep. How can this be done. Please help (5 Replies)
Discussion started by: proactiveaditya
5 Replies

8. Shell Programming and Scripting

Sum of range of rows and columns in matrix

Hi all, I have a large matrix of 720 x 25. I want to get sum of range of rows and columns. Like, I need sum of all columns and row number 2 to 21, then leaving 22nd row, again sum of all columns and row number 23 to 42 again leaving 43rd row and then sum of 44th to 63. Means I want to add all... (4 Replies)
Discussion started by: CAch
4 Replies

9. Shell Programming and Scripting

Reading specific range of columns in an Excel file

Hi All, I want to read an excel file. PFA excel, I want to read the cloumn from A to G and the V to AH starting from Row number 3. Please help me on this. (7 Replies)
Discussion started by: Abhisrajput
7 Replies

10. UNIX for Beginners Questions & Answers

Removing letters after a certain character within a range of columns

Hi there, I am trying to remove al letters after : character on specific columns from 10th column till 827. I used sed and cut to do so but I am sure there is better one liner someone can think of from unix community members. Huge file but it has this structure (Total number of Columns =... (10 Replies)
Discussion started by: daashti
10 Replies
MSG_SET_QUEUE(3)							 1							  MSG_SET_QUEUE(3)

msg_set_queue - Set information in the message queue data structure

SYNOPSIS
bool msg_set_queue (resource $queue, array $data) DESCRIPTION
msg_set_queue(3) allows you to change the values of the msg_perm.uid, msg_perm.gid, msg_perm.mode and msg_qbytes fields of the underlying message queue data structure. Changing the data structure will require that PHP be running as the same user that created the queue, owns the queue (as determined by the existing msg_perm.xxx fields), or be running with root privileges. root privileges are required to raise the msg_qbytes values above the system defined limit. PARAMETERS
o $queue - Message queue resource handle o $data - You specify the values you require by setting the value of the keys that you require in the $data array. RETURN VALUES
Returns TRUE on success or FALSE on failure. SEE ALSO
msg_remove_queue(3), msg_receive(3), msg_stat_queue(3), msg_get_queue(3). PHP Documentation Group MSG_SET_QUEUE(3)
All times are GMT -4. The time now is 06:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy