Sponsored Content
Top Forums Shell Programming and Scripting compare two files and search keyword and print output Post 302477040 by cdfd123 on Friday 3rd of December 2010 06:13:18 AM
Old 12-03-2010
Quote:
Originally Posted by rbatte1
This is just
Code:
grep -f FileB FileA > outputFile

Some implementations may use fgrep instead though, depending what flags are supported.

The code in the previous post could be very slow depending on the data volumes, however it could be adapted to include the square brackets or force other conditions on the search for the string. It depends what you are actually after.


U r Right
fgrep is faster here while running this compared as comapred to grep
Thanks


I hope that this helps. Let us all know if I have missed the point.


Robin
Liverpool/Blackburn
UK
---------- Post updated at 06:13 AM ---------- Previous update was at 06:12 AM ----------

Quote:
Originally Posted by rbatte1
This is just
Code:
grep -f FileB FileA > outputFile

Some implementations may use fgrep instead though, depending what flags are supported.

The code in the previous post could be very slow depending on the data volumes, however it could be adapted to include the square brackets or force other conditions on the search for the string. It depends what you are actually after.





I hope that this helps. Let us all know if I have missed the point.


Robin
Liverpool/Blackburn
UK
U r Right
fgrep is faster here while running this compared as comapred to grep
Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using awk to search and print output

suppose i have one file file A 18 24 30 35 38 45 55 Another file file B 08_46 A 16 V -0.36 0.23 E : 1.41 08_46 A 17 D -1.04 0.22 E : 0.84 08_46 A 18 Q -0.49 0.12 E : 0.06 08_46 A 19 G 0.50 0.14 E : 0.05 08_46 A 20 V ... (5 Replies)
Discussion started by: cdfd123
5 Replies

2. Shell Programming and Scripting

awk to compare lines of two files and print output on screen

hey guys, I have two files both with two columns, I have already created an awk code to ignore certain lines (e.g lines that start with 963) as they wou ld begin with a certain string, however, the rest I have added together and calculated the average. At the moment the code also displays... (3 Replies)
Discussion started by: chlfc
3 Replies

3. Shell Programming and Scripting

compare columns from seven files and print the output

Hi guys, I need some help to come out with a solution . I have seven such files but I am showing only three for convenience. filea a5 20 a8 16 fileb a3 42 a7 14 filec a5 23 a3 07 The output file shoud contain the data in table form showing first field of... (7 Replies)
Discussion started by: smriti_shridhar
7 Replies

4. Shell Programming and Scripting

awk to compare flat files and print output to another file

Hello, I am strugling from quite a some time to compare flat files with over 1 million records could anyone please help me. I want to compare two pipe delimited flat files, file1 with file2 and output the unmatched rows from file2 in file3 Sample File1: ... (9 Replies)
Discussion started by: suhaeb
9 Replies

5. UNIX for Advanced & Expert Users

Shell Script to compare xml files and print output to a file

All, PLease can you help me with a shell script which can compare two xml files and print the difference to a output file. I have attached one such file for you reference. <Group> <Member ID=":Year_Quad:41501" childCount="4" fullPath="PEPSICO Year-Quad-Wk : FOLDER.52 Weeks Ending Dec... (2 Replies)
Discussion started by: kanthrajgowda
2 Replies

6. Shell Programming and Scripting

Keyword search/replace for two text files?

What is the best way (bash/awk/sed?) to read in two text files and do a keyword search/replace? file1.txt: San Francisco Los Angeles Seattle Dallas file2.txt: I love Los Angeles. Coming to Dallas was the right choice. San Francisco is fun. Go to Seattle in the summer. ... (3 Replies)
Discussion started by: pxalpine
3 Replies

7. Shell Programming and Scripting

Compare columns of multiple files and print those unique string from File1 in an output file.

Hi, I have multiple files that each contain one column of strings: File1: 123abc 456def 789ghi File2: 123abc 456def 891jkl File3: 234mno 123abc 456def In total I have 25 of these type of file. (5 Replies)
Discussion started by: owwow14
5 Replies

8. Shell Programming and Scripting

Search for a Keyword in file and replace another keyword or add at the end of line

Hi I want to implement something like this: if( keyword1 exists) then check if(keyword2 exists in the same line) then replace keyword 2 with New_Keyword else Add New_Keyword at the end of line end if eg: Check for Keyword JUNGLE and add/replace... (7 Replies)
Discussion started by: dashing201
7 Replies

9. Shell Programming and Scripting

awk script to search output for a value and print

GOODNUMBERS="1 2 3 4 5 6 3 3 34 34 5 66 12" BADNUMBERS="7 3 12 5 66" for eachnum in `echo ${GOODNUMBERS}` do echo ${BADNUMBERS} | gawk -v threshold=${eachnum} '$1 != threshold' done what im trying to do with the above is, i want to print numbers that are in the GOODNUMBERS... (10 Replies)
Discussion started by: SkySmart
10 Replies

10. UNIX for Beginners Questions & Answers

Compare two files and print output

Hi All, i am trying to compare two files in Centos 6. F1: /tmp/d21 NAME="xvda" TYPE="disk" SIZE="40G" OWNER="root" GROUP="disk" MODE="brw-rw----" MOUNTPOINT="" NAME="xvda1" TYPE="part" SIZE="500M" OWNER="root" GROUP="disk" MODE="brw-rw----" MOUNTPOINT="/boot" NAME="xvda2" TYPE="part"... (2 Replies)
Discussion started by: balu1234
2 Replies
RCSDIFF(1)						      General Commands Manual							RCSDIFF(1)

NAME
rcsdiff - compare RCS revisions SYNOPSIS
rcsdiff [ -ksubst ] [ -q ] [ -rrev1 [ -rrev2 ] ] [ -T ] [ -V[n] ] [ -xsuffixes ] [ -zzone ] [ diff options ] file ... DESCRIPTION
rcsdiff runs diff(1) to compare two revisions of each RCS file given. Pathnames matching an RCS suffix denote RCS files; all others denote working files. Names are paired as explained in ci(1). The option -q suppresses diagnostic output. Zero, one, or two revisions may be specified with -r. The option -ksubst affects keyword sub- stitution when extracting revisions, as described in co(1); for example, -kk -r1.1 -r1.2 ignores differences in keyword values when compar- ing revisions 1.1 and 1.2. To avoid excess output from locker name substitution, -kkvl is assumed if (1) at most one revision option is given, (2) no -k option is given, (3) -kkv is the default keyword substitution, and (4) the working file's mode would be produced by co -l. See co(1) for details about -T, -V, -x and -z. Otherwise, all options of diff(1) that apply to regular files are accepted, with the same meaning as for diff. If both rev1 and rev2 are omitted, rcsdiff compares the latest revision on the default branch (by default the trunk) with the contents of the corresponding working file. This is useful for determining what you changed since the last checkin. If rev1 is given, but rev2 is omitted, rcsdiff compares revision rev1 of the RCS file with the contents of the corresponding working file. If both rev1 and rev2 are given, rcsdiff compares revisions rev1 and rev2 of the RCS file. Both rev1 and rev2 may be given numerically or symbolically. EXAMPLE
The command rcsdiff f.c compares the latest revision on the default branch of the RCS file to the contents of the working file f.c. ENVIRONMENT
RCSINIT options prepended to the argument list, separated by spaces. See ci(1) for details. DIAGNOSTICS
Exit status is 0 for no differences during any comparison, 1 for some differences, 2 for trouble. IDENTIFICATION
Author: Walter F. Tichy. Manual Page Revision: 5.5; Release Date: 1993/11/03. Copyright (C) 1982, 1988, 1989 Walter F. Tichy. Copyright (C) 1990, 1991, 1992, 1993 Paul Eggert. SEE ALSO
ci(1), co(1), diff(1), ident(1), rcs(1), rcsintro(1), rcsmerge(1), rlog(1) Walter F. Tichy, RCS--A System for Version Control, Software--Practice & Experience 15, 7 (July 1985), 637-654. GNU
1993/11/03 RCSDIFF(1)
All times are GMT -4. The time now is 10:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy