File Reference Matching


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File Reference Matching
# 8  
Old 07-11-2015
Quote:
Originally Posted by bakunin
... ... ...

Absolutely correct, but this (or any solution derived from it) would have nothing to do with the shell or the system - just with the willingness to undergo the effort to actually modify it into a fitting form.

... ... ...

bakunin
You might note that in post #2 in this thread I didn't ask about the shell being used (partly because it doesn't matter here and partly because bash had already been specified).

I did ask about the OS, and it does matter here if an awk solution is appropriate (as in the suggestion I would provide if ChicagoBlues showed us that any effort had been put into this problem) since on Solaris systems awk would need to be changed to /usr/xpg4/bin/awk or nawk.

Also, the shell does matter more on Solaris systems than on many other systems since /bin/sh there is a pure Bourne shell lacking several standard shell parameter expansions, arithmetic expansions, and the $(command) form of command substitution.
# 9  
Old 07-13-2015
A simple grep against the whole file worked for me (within the loop). Initially, I wasn't thinking of wrapping it in a loop. If you have a more efficient solution, then please share.

Code:
  for platform in $(cat $DATA_OUT/tmp_ALLL_Platforms.txt); do
    warning=`grep $platform $DATA_OUT/ALL_warnings.txt`

    ... rest of the code

    done

# 10  
Old 07-13-2015
For the original problem you posed in post #1 in this thread, the following works perfectly:
Code:
/usr/xpg4/bin/awk -F'[";]' '
FNR == NR {
	t[$2] = $0
	next
}
{	print t[$2]
}' tmp.new tmp.orig

But, since the data you showed us in post #1 would not find any matches with the code you showed us in post #9, I have to assume that the data you showed us is not representative of your actual data.
# 11  
Old 07-13-2015
Quote:
for platform in $(cat $DATA_OUT/tmp_ALLL_Platforms.txt);
A for loop is not good when you need to read from a file. You could eliminate an extra call to the cat command by using a while loop.

Code:
while read platform; do
    do something here with $platform
done < "${DATA_OUT}"/tmp_ALLL_Platforms.txt

Concerning your request.
Code:
tr -d \" < tmp.orig | grep -Ff - tmp.new
"TEST1;921"
"TEST2;34"
"TEST5;98"
"TEST6;1"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Solaris 11 patch cross reference file

Hi all I wanted to know does solaris 11 have any place to download patch cross-reference file like solaris 10 (h t t p s://getupdates.oracle.com/reports/patchdiag.xref)? I wanted to use this file to filter out those security patches and use it to check if any of my solaris 11 systems are... (0 Replies)
Discussion started by: kaze
0 Replies

2. UNIX for Dummies Questions & Answers

awk to replace values in one file using a second reference file

Hi, I'd be grateful for your help with the following: I have a file with a single column (file1). Let's say the values are: a b c 5 d I have a second, reference file (ref_file), which is colon-delimited, and is effectively a key. Let's say the values in it are: a:1 b:2 c:3 d:4... (4 Replies)
Discussion started by: aberg
4 Replies

3. Shell Programming and Scripting

Compare data with reference from other file

Gents, Please can you help with this. I have a big file (file2) which contends many records increment every 25 rows ( column 1 ). Then I have other file as reference (file1).. column 1 to 11. I want to compare that all values in file2 (column 2 to 12.) match with values in... (2 Replies)
Discussion started by: jiam912
2 Replies

4. Shell Programming and Scripting

Reading reference file

For file purge and archive script, I am planing to have the reference files as below for various file system. >ReferenceFile.cfg ... ... DailyArchive: { FOLDERS PATERN DAYS_TO_RETAIN MINIMUM_SIZE_THESHOLD(MB) /aaa/bbb/ * 3 300... (4 Replies)
Discussion started by: deepakwins
4 Replies

5. Shell Programming and Scripting

Keeping record of file 2 based on a reference file 1 in awk

I have 2 input files (tab separated): file1: make_A 1990 foo bar make_B 2010 this that make_C 2004 these those file2: make_X 1970 1995 ref_1:43 ref_2:65 make_A 1970 1995 ref_1:4 ref_2:21 ref_3:18 make_A 1980 2002 ref_1:7 ref_2:7 ref_3:0 ... (2 Replies)
Discussion started by: beca123456
2 Replies

6. Shell Programming and Scripting

Replace a value using a reference data from other file

Gents, Can you please help me to solve this case In my input file I have a values in column 49 which always need to be one, but sometimes the system create a value 2, in this case I need to go to search in the original file and replace the values in the row where the value 2 is and in the... (6 Replies)
Discussion started by: jiam912
6 Replies

7. Shell Programming and Scripting

Replace from reference file awk

Basically want to replace any field in input file from the refernce file ... for example. clar_2400:3113 in input file will be replaced by clar_2400:3113 Input file field seperator is "," Field which is not found in reference will stay as it is ... Input File ... (3 Replies)
Discussion started by: greycells
3 Replies

8. Shell Programming and Scripting

Perl de-reference code reference variable

Guys, May i know how can we de reference the code reference variable.? my $a = sub{$a=shift;$b=shift;print "SUM:",($a+$b),"\n";}; print $a->(4,5); How can we print the whole function ? Please suggest me regarding this. Thanks for your time :) Cheers, Ranga :) (0 Replies)
Discussion started by: rangarasan
0 Replies

9. Programming

Help to filter read through reference file by using c language

Input_file #tmp_2 werweraewghe @tmp_2 123sdfs57a #tmp_1 aewrgheheghe @tmp_1 457awrerfa87 #tmp_4 trtyrghe @tmp_4 8898rtyr2 reference_file #tmp_4 #tmp_1 (14 Replies)
Discussion started by: cpp_beginner
14 Replies

10. Shell Programming and Scripting

Help with replace column one content based on reference file

Input file 1 testing 10 20 1 A testing 20 40 1 3 testing 23 232 2 1 testing 10 243 2 . . Reference file 1 final 3 used . . Output file (1 Reply)
Discussion started by: perl_beginner
1 Replies
Login or Register to Ask a Question