Sponsored Content
Full Discussion: search pattern and mark/tag
Top Forums Shell Programming and Scripting search pattern and mark/tag Post 302510730 by rdcwayx on Monday 4th of April 2011 08:12:11 PM
Old 04-04-2011
I guess this is homework, but since Alister has provided the solution, I'd like to provide the other.
Code:
awk 'NR==FNR{a[$1]=$2;next}{print $0,a[$1]}' pattern.file input.file

@ saint2006

Looks you can compare the mark directly in input.file to report the student fail or pass.

If you really want to learn shell, you can try to use input.file get the result directly. Compare the marks if both are great than 60, will be pass, otherwise, will be fail.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Can and How to mark search strings within VI?

Hi all, When in 'less' or '-' or whatever your alias is, if you search for a string, you get all of it's occurences highlighted. Is there any option I can set in VI, .exrc or whtever, to have the same behaviour in VI? thanks (2 Replies)
Discussion started by: sierra_aar
2 Replies

2. Shell Programming and Scripting

search a pattern and if pattern found insert new pattern at the begining

I am trying to do some thing like this .. In a file , if pattern found insert new pattern at the begining of the line containing the pattern. example: in a file I have this. gtrow0unit1/gctunit_crrownorth_stage5_outnet_feedthru_pin if i find feedthru_pin want to insert !! at the... (7 Replies)
Discussion started by: pitagi
7 Replies

3. UNIX for Dummies Questions & Answers

tag/mark a file with current absolute path

Hi all, I need to mark a file with it's current location in the file system before being moved. This will enable the file to be restored back to it's original location. Can anyone provide any ideas about the best way to do this, at present i'm trying to use readlink -m to strip off the... (1 Reply)
Discussion started by: skinnygav
1 Replies

4. Shell Programming and Scripting

solved -gawk, search for pattern - mark the previous line as a variable?

Im trying to parse ifconfig with awk and setup a bunch of variables in one shot. But Im having trouble figuring out how to work with data in previous lines. ifconfig output: eth0 Link encap:Ethernet HWaddr 00:50:DA:10:7F:1B inet addr:10.10.10.10 Bcast:10.10.10.127 ... (0 Replies)
Discussion started by: trey85stang
0 Replies

5. Shell Programming and Scripting

Search for particular tag and arrange as coordinates

Hi I have a file whose sample contents are shown here, 1.2.3.4->2.4.2.4 a(10) b(20) c(30) 1.2.3.4->2.9.2.4 a(10) c(20) 2.3.4.3->3.6.3.2 b(40) d(50) c(20) 2.3.4.3->3.9.0.2 a(40) e(50) c(20) 1.2.3.4->3.4.2.4 a(10) c(30) 6.2.3.4->2.4.2.5 c(10) . . . . Here I need to search... (5 Replies)
Discussion started by: AKD
5 Replies

6. Shell Programming and Scripting

Search and filter by TAG

Hello all, searching on a text file (log file) is quite simple: grep -i texttosearch filename | grep somethingWhat I'm trying to do is filter the result by TAG and remove the double entries. Like if the log file contains the following text (fields are separated by commas): ... (18 Replies)
Discussion started by: Lord Spectre
18 Replies

7. Shell Programming and Scripting

Multiple Tag Search and Printing

Scenario: The following text belongs to a .doc file File: check1.asmFunction: MonksTag: NoTag: 001Tag: YesTag: 002File: check2.asmFunction: Perl MonksTag: YesTag: 003Tag: NoTag: 004File: check3.asmFunction: ExpertsTag: NoTag: 005Tag: NoTag: 006Function: Perl ExpertsTag: NoTag: 007Tag: YesTag: 008... (1 Reply)
Discussion started by: rajkrishna89
1 Replies

8. Shell Programming and Scripting

Search for a html tag and print the entire tag

I want to print from <fruits> to </fruits> tag which have <fruit> as mango. Also i want both <fruits> and </fruits> in output. Please help eg. <fruits> <fruit id="111">mango<fruit> . another 20 lines . </fruits> (3 Replies)
Discussion started by: Ashik409
3 Replies

9. Shell Programming and Scripting

To search for a particular tag in xml and collate all similar tag values and display them count

I want to basically do the below thing. Suppose there is a tag called object1. I want to display an output for all similar tag values under heading of Object 1 and the count of the xmls. Please help File: <xml><object1>house</object1><object2>child</object2>... (9 Replies)
Discussion started by: srkmish
9 Replies

10. UNIX for Beginners Questions & Answers

Grep/awk using a begin search pattern and end search pattern

I have this fileA TEST FILE ABC this file contains ABC; TEST FILE DGHT this file contains DGHT; TEST FILE 123 this file contains ABC, this file contains DEF, this file contains XYZ, this file contains KLM ; I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Discussion started by: vbabz
2 Replies
Data::Compare(3)					User Contributed Perl Documentation					  Data::Compare(3)

NAME
Data::Compare - compare perl data structures SYNOPSIS
use Data::Compare; my $h1 = { 'foo' => [ 'bar', 'baz' ], 'FOO' => [ 'one', 'two' ] }; my $h2 = { 'foo' => [ 'bar', 'barf' ], 'FOO' => [ 'one', 'two' ] }; my @a1 = ('one', 'two'); my @a2 = ('bar', 'baz'); my %v = ( 'FOO', @a1, 'foo', @a2 ); # simple procedural interface print 'structures of $h1 and \%v are ', Compare($h1, \%v) ? "" : "not ", "identical. "; print 'structures of $h1 and $h2 are ', Compare($h1, $h2, { ignore_hash_keys => [qw(foo)] }) ? '' : 'not ', "close enough to identical. "; # OO usage my $c = new Data::Compare($h1, \%v); print 'structures of $h1 and \%v are ', $c->Cmp ? "" : "not ", "identical. "; # or my $c = new Data::Compare; print 'structures of $h and \%v are ', $c->Cmp($h1, \%v) ? "" : "not ", "identical. "; DESCRIPTION
Compare two perl data structures recursively. Returns 0 if the structures differ, else returns 1. A few data types are treated as special cases: Scalar::Properties objects This has been moved into a plugin, although functionality remains the same as with the previous version. Full documentation is in Data::Compare::Plugins::Scalar::Properties. Compiled regular expressions, eg qr/foo/ These are stringified before comparison, so the following will match: $r = qr/abc/i; $s = qr/abc/i; Compare($r, $s); and the following won't, despite them matching *exactly* the same text: $r = qr/abc/i; $s = qr/[aA][bB][cC]/; Compare($r, $s); Sorry, that's the best we can do. CODE and GLOB references These are assumed not to match unless the references are identical - ie, both are references to the same thing. You may also customise how we compare structures by supplying options in a hashref as a third parameter to the "Compare()" function. This is not yet available through the OO-ish interface. These options will be in force for the *whole* of your comparison, so will apply to structures that are lurking deep down in your data as well as at the top level, so beware! ignore_hash_keys an arrayref of strings. When comparing two hashes, any keys mentioned in this list will be ignored. CIRCULAR STRUCTURES
Comparing a circular structure to itself returns true: $x = $y; $y = $x; Compare([$x, $y], [$x, $y]); And on a sort-of-related note, if you try to compare insanely deeply nested structures, the module will spit a warning. For this to affect you, you need to go around a hundred levels deep though, and if you do that you have bigger problems which I can't help you with ;-) PLUGINS
The module takes plug-ins so you can provide specialised routines for comparing your own objects and data-types. For details see Data::Compare::Plugins. Plugins are *not* available when running in "taint" mode. You may also make it not load plugins by providing an empty list as the argument to import() - ie, by doing this: use Data::Compare (); A couple of functions are provided to examine what goodies have been made available through plugins: plugins Returns a structure (a hash ref) describing all the comparisons made available through plugins. This function is *not* exported, so should be called as Data::Compare::plugins(). It takes no parameters. plugins_printable Returns formatted text EXPORTS
For historical reasons, the Compare() function is exported. If you don't want this, then pass an empty list to import() as explained under PLUGINS. If you want no export but do want plugins, then pass the empty list, and then call the register_plugins class method: use Data::Compare (); Data::Compare->register_plugins; or you could call it as a function if that floats your boat. SOURCE CODE REPOSITORY
<git://github.com/DrHyde/perl-modules-Data-Compare.git> BUGS
Plugin support is not quite finished (see the TODO file for details) but is usable. The missing bits are bells and whistles rather than core functionality. Please report any other bugs either by email to David Cantrell (see below for address) or using rt.cpan.org: <https://rt.cpan.org/Ticket/Create.html?Queue=Data-Compare> AUTHOR
Fabien Tassin <fta@sofaraway.org> Portions by David Cantrell <david@cantrell.org.uk> COPYRIGHT and LICENCE Copyright (c) 1999-2001 Fabien Tassin. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Some parts copyright 2003 - 2013 David Cantrell. Seeing that Fabien seems to have disappeared, David Cantrell has become a co-maintainer so he can apply needed patches. The licence, of course, remains the same. As the "perl licence" is "Artistic or GPL, your choice", you can find them as the files ARTISTIC.txt and GPL2.txt in the distribution. SEE ALSO
perl(1), perlref(1) perl v5.18.2 2013-09-26 Data::Compare(3)
All times are GMT -4. The time now is 08:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy