Sponsored Content
Top Forums Shell Programming and Scripting Compare value of a column in a file Post 302851427 by Vivekit82 on Monday 9th of September 2013 12:08:10 AM
Old 09-09-2013
hi..Thanks for the reply.
but input value can be anything..There are more than 1000 records in the file in a similar pattern.There should be some loop etc.
I dont want to hardcode the input values.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I need to extract last column of a file and compare the values

Hi, I am new to unix and I need help in solving below mentioned issue, really appreciate ur help. I have a file sam, john, 2324, 07142007 tom, thomson, 2343, 07142007 john, scott, 2478, 07142007 its a comma delimited file, I need to extract the last column from each line and this... (4 Replies)
Discussion started by: vukkusila
4 Replies

2. Shell Programming and Scripting

Compare between column in one file

Hi all, can anyone help me. I want to compare values within column in one file using awk. Below are the sample input file(1st file):... (6 Replies)
Discussion started by: lurak
6 Replies

3. Shell Programming and Scripting

awk compare column n replace with in one file

hi Friends need to compare columns in one file where the data looks like below laptop,IBM phone,samsung car,rental user1,laptop user2,laptop user3,phone want to get output as laptop,IBM phone,samsung car,rental user1,IBM user2,IBM user3,samsung need to seach $2 in array of $1 and... (4 Replies)
Discussion started by: arun1401
4 Replies

4. UNIX for Dummies Questions & Answers

Compare two column in file and extract complate line

No Chr Pos Qual GT_1 GT_2 1. chr1 478493 595 A/G G/G 2. chr1 879243 700 A/T T/T 3. chr2 889922 1300 C/C C/C 4. chr2 1926372 300 T/A T/A 5. chr3 237474 500 G/C C/C 6. chr3 575757 700 ... (2 Replies)
Discussion started by: mscott
2 Replies

5. Shell Programming and Scripting

Compare the second column of a file with the second column of another in awk

Hi, I know that this topic has been discussed in the past and I've tried to follow all the guidelines. Anyhow, I following describe my problem. I have a file (file1 , no. records = 67) containing pairs of IP addresses as follows (with single space as delimiter between the fields): example... (5 Replies)
Discussion started by: amarn
5 Replies

6. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

7. Shell Programming and Scripting

How to compare the values of a column in a same file using awk?

Dear Unix experts, I have got a file where I would like to compare the values of second column if first column is same in such a way that the difference between the values is >50. If not, I would like to discard both values. For example, my input file looks like - comp275_c0_seq2 73... (7 Replies)
Discussion started by: utritala
7 Replies

8. UNIX for Beginners Questions & Answers

Compare Values between column in the same file

Input File:- COLUMN1 COLUMN2 COLUMN3 COLUMN4 COLUMN5 COLUMN6 SMS Email AO Mail Post N Cell VEGE Potato E W 396 12 0 384 0 0 0 0 0 VEGE Onion S W 17 0 17 0 0 0 0 0 0 FRUIT APPLE N W 549 61 0 0 0 0 0 488 0 FRUIT APPLE SE W 291 14 239 38 0 10 0 0 0 FRUIT APPLE EAMS W 397 32 309 56 309 309 0... (27 Replies)
Discussion started by: Nina2910
27 Replies

9. UNIX for Beginners Questions & Answers

Compare 1st column from 2 file and if match print line from 1st file and append column 7 from 2nd

hi I have 2 file with more than 10 columns for both 1st file apple,0,0,0...... orange,1,2,3..... mango,2,4,5..... 2nd file apple,2,3,4,5,6,7... orange,2,3,4,5,6,8... watermerlon,2,3,4,5,6,abc... mango,5,6,7,4,6,def.... (1 Reply)
Discussion started by: tententen
1 Replies
AGREP(1)						    BSD General Commands Manual 						  AGREP(1)

NAME
agrep -- print lines approximately matching a pattern SYNOPSIS
agrep [options] pattern [files] DESCRIPTION
Searches for approximate matches of pattern in each FILE or standard input. OPTIONS
Regexp selection and interpretation -e pattern, --regexp=pattern Use PATTERN as a regular expression; useful to protect patterns beginning with '-'. -i, --ignore-case Ignore case distinctions (as defined by the current locale) in pattern and input files. -k, --literal Treat pattern as a literal string, that is, a fixed string with no special characters. -w, --word-regexp Force pattern to match only whole words. A ``whole word'' is a substring which either starts at the beginning or the record or is preceded by a non-word constituent character. Similarly, the substring must either end at the end of the record or be fol- lowed by a non-word constituent character. Word-constituent characters are alphanumerics (as defined by the current locale) and the underscore character. Note that the non-word constituent characters must surround the match; they cannot be counted as errors. Approximate matching settings -D num, --delete-cost=num Set cost of missing characters to num. -I num, --insert-cost=num Set cost of extra characters to num. -S num, --substitue-cost=num Set cost of incorrect characters to num. Note that a deletion (a missing character) and an insertion (an extra character) together constitute a substituted character, but the cost will be the that of a deletion and an insertion added together. Thus, if the const of a substitution is set to be larger than the sum of the costs of deletion and insertion, direct substitutions will never be done. -E -num, --max-errors=num Select records that have at most num errors. -# Select records that have at most # errors (# is a digit between 0 and 9). Miscellaneous -d -pattern, --delimiter=pattern Set the record delimiter regular expression to pattern. The text between two delimiters, before the first delimiter, and after the last delimiter is considered to be a record. The default record delimiter is the regexp `` '', so by default a record is a line. pattern can be any regular expression that does not match the empty string. For example, using -d file ... defines mail messages as records in a Mailbox format file. -v, --invert-match Select non-matching records instead of matching records. -V, --version Print version information and exit. -y, --nothing Does nothing. This options exists only for compatibility with the non-free agrep program. --help Display a brief help message and exit. Output control -B, --best-match Only output the best matching records, that is, the records with the lowest cost. This is currently implemented by making two passes over the input files and cannot be used when reading from standard input. --color, --colour Highlight the matching strings in the output with a color marker. The color string is taken from the GREP_COLOR environment variable. The default color is red. -c, --count Only print a count of matching records per each input file, suppressing normal output. -h, --no-filename Suppress the prefixing filename on output when multiple files are searched. -H, --with-filename Prefix each output record with the name of the input file where the record was read from. -l, --files-with-matches Only print the name of each input file which contains at least one match, suppressing normal output. The scanning for each file will stop on the first match. -n, --record-number Prefix each output record with its sequence number in the input file. The number of the first record is 1. -q, --quiet, --silent Do not write anything to standard output. Exit immediately with zero exit status if a match is found. -s, --show-cost Print match cost with output. --show-position Prefix each output record with the start and end offset of the first match within the record. The offset of the first character of the record is 0. The end position is given as the offset of the first character after the match. -M, --delimiter-after By default, the record delimiter is the newline character and is output after the matching record. If -d is used, the record delimiter will be output before the matching record. This option causes the delimiter to be output after the matching record. With no file, or when file is ``-'', agrep reads standard input. If less than two files are given -h is assumed, otherwise -H is the default. EXAMPLES
agrep -2 optimize foo.txt outputs all lines in file foo.txt that match ``optimize'' within two errors. E.g. lines which contain ``optimise'', ``optmise'', and ``opitmize'' all match. DIAGNOSTICS
Exit status is 0 if a match is found, 1 for no match, and 2 if there were errors. If -E or -# is not specified, only exact matches are selected. pattern is a POSIX extended regular expression (ERE) with the TRE extensions. REPORTING BUGS
Report bugs to the TRE mailing list <tre-general@lists.laurikari.net>. COPYRIGHT
Copyright (C) 2002-2004 Ville Laurikari. This is free software, and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute this software under certain conditions; see the source for the full license text. BSD
November 21, 2004 BSD
All times are GMT -4. The time now is 04:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy