Sponsored Content
Top Forums Shell Programming and Scripting Find out the match data content?! Post 302368026 by rdcwayx on Wednesday 4th of November 2009 03:52:12 AM
Old 11-04-2009
With -m, can save the search time.

-m NUM, --max-count=NUM
Stop reading a file after NUM matching lines. If the input is standard input from a regular
file, and NUM matching lines are output, grep ensures that the standard input is positioned to
just after the last matching line before exiting, regardless of the presence of trailing
context lines. This enables a calling process to resume a search. When grep stops after NUM
matching lines, it outputs any trailing context lines. When the -c or --count option is also
used, grep does not output a count greater than NUM. When the -v or --invert-match option is
also used, grep stops after outputting NUM non-matching lines.

Code:
grep -m 1 -f file1 file2

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

X11 auth data does not match fake data

We have different unix servers, let say I have server 1 and server 2. Well whenever I ssh from server 1 to server 2, I'm ok, but when I ssh from server 2 to server 1, I can connect just fine, but I get this message: X11 auth data does not match fake data X11 auth data does not match fake data... (1 Reply)
Discussion started by: samytrix
1 Replies

2. Shell Programming and Scripting

How to find first match and last match in a file

Hi All, I have a below file: ================== 02:53 pravin-root 02:53 pravin-root 03:05 pravin-root 02:55 pravin1-root 02:59 pravin1-root ================== How do I find the first and last value of column 1. For example, how do I find 02:53 is the first time stamp and 03:05 is... (3 Replies)
Discussion started by: praving5
3 Replies

3. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

4. Shell Programming and Scripting

Extract specific data content from a long list of data

My input: Data name: ABC001 Data length: 1000 Detail info Data Direction Start_time End_time Length 1 forward 10 100 90 1 forward 15 200 185 2 reverse 50 500 450 Data name: XFG110 Data length: 100 Detail info Data Direction Start_time End_time Length 1 forward 50 100 50 ... (11 Replies)
Discussion started by: patrick87
11 Replies

5. Shell Programming and Scripting

Extract all content that match exactly only specific word

Input: 21 templeta parent 35718 36554 . - . ID=parent_cluster_50.21.11; Name=Partial%20parent%20for%20training%20set; 21 templeta kids 35718 36554 . - . ID=_52; Parent=parent_cluster_5085.21.11; 21 templeta ... (7 Replies)
Discussion started by: patrick87
7 Replies

6. Shell Programming and Scripting

Column content match and add suffix

My input chr3 galGal3_xenoRefFlat CDS 4178235 4178264 0.000000 + 0 gene_id "T6J4.19; T6J4_19"; transcript_id "T6J4.19; T6J4_19"; chr3 galGal3_xenoRefFlat exon 4178235 4178264 0.000000 + . gene_id "T6J4.19; T6J4_19"; transcript_id "T6J4.19;... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

7. Shell Programming and Scripting

Program to match the id and replace one letter in the content

Hi all, I have one file with a sequence and the other file which says the position and the letter to be changed. I have to match two files and replace content. Example is shown which will describe what I want to do. For example, file 1 has many sequences and few are shown below sequence file:... (6 Replies)
Discussion started by: kaav06
6 Replies

8. Shell Programming and Scripting

Sorting content between match pattern and move on with awk and sed

S 0.0 0.0 (reg, inst050) k e f d c S 0.0 0.0 (mux, m030) k g r s x v S 0.0 0.0 (reg, inst020) q s n m (12 Replies)
Discussion started by: ctphua
12 Replies

9. Shell Programming and Scripting

awk command to get file content until 2 occurrence of pattern match

AWK command to get file content until 3 occurrence of pattern match, INPUT FILE: JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <custOptIn xmlns="http://com/walm/ta/cu/ccs/xml2"> <person>Romi</person> <appName>SAP</appName> </custOptIn> ... (4 Replies)
Discussion started by: prince1987
4 Replies

10. UNIX for Beginners Questions & Answers

Data match 2 files based on first 2 columns matching only and join if match

Hi, i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file I have tried with join and awk and i keep getting blank outputs or same file is there an easier way than what i am... (4 Replies)
Discussion started by: axis88
4 Replies
ZMQ_MSG_MOVE(3) 						    0MQ Manual							   ZMQ_MSG_MOVE(3)

NAME
zmq_msg_move - move content of a message to another message SYNOPSIS
int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src); DESCRIPTION
The zmq_msg_move() function shall move the content of the message object referenced by src to the message object referenced by dest. No actual copying of message content is performed, dest is simply updated to reference the new content. src becomes an empty message after calling zmq_msg_move(). The original content of dest, if any, shall be released. Caution Never access zmq_msg_t members directly, instead always use the zmq_msg family of functions. RETURN VALUE
The zmq_msg_move() function shall return zero if successful. Otherwise it shall return -1 and set errno to one of the values defined below. ERRORS
EFAULT Invalid message. SEE ALSO
zmq_msg_copy(3) zmq_msg_init(3) zmq_msg_init_size(3) zmq_msg_init_data(3) zmq_msg_close(3) zmq(7) AUTHORS
This manual page was written by the 0MQ community. 0MQ 2.2.0 04/04/2012 ZMQ_MSG_MOVE(3)
All times are GMT -4. The time now is 03:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy