Sponsored Content
Top Forums Shell Programming and Scripting awk cross-referencing between two files Post 302528027 by origamisven on Monday 6th of June 2011 09:45:42 AM
Old 06-06-2011
awk cross-referencing between two files

I need to make my sloppy, existing code (non awk) more efficient and I seem to be terrible with awk Smilie

I've tried around quite a bit, maybe you guys can conjure up a quick solution...

file1:

Code:
2 SOL 563
      2 SOL 565
      3 SOL 589
      2 SOL 603
      1 SOL 612
      1 SOL 621
      2 SOL 623
3 SOL 770
      3 SOL 771
      3 SOL 772
      3 SOL 773
2 SOL 774



file 2:
Code:
ATOM  58262   OW SOL  18120     27.770  75.370 125.740
ATOM  58263  HW1 SOL  18120     28.020  75.170 124.790
ATOM  58264  HW2 SOL  18120     28.490  75.930 126.160
ATOM  58265   OW SOL  18121     28.420  85.640 128.910
ATOM  58266  HW1 SOL  18121     27.430  85.700 129.010
ATOM  58267  HW2 SOL  18121     28.650  84.840 128.350
ATOM  58268   OW SOL  18122     25.670  84.980 115.400
ATOM  58269  HW1 SOL  18122     25.530  85.050 116.390
ATOM  58270  HW2 SOL  18122     26.510  84.470 115.220
ATOM  58271   OW SOL  18123     22.720  82.610 124.230
ATOM  58272  HW1 SOL  18123     23.580  82.730 124.730
ATOM  58273  HW2 SOL  18123     22.300  81.740 124.500
ATOM  58274   OW SOL  18124     31.360  78.340 124.340
ATOM  58275  HW1 SOL  18124     31.570  79.080 124.980
ATOM  58276  HW2 SOL  18124     30.470  78.510 123.910


So basically what I need is this...

1) check every line of file1/column1 for values smaller than 3
2) if true then read value of file1/column3
3) cross-reference value of file1/column3 with value of file2/column5
4) if match found then delete line from file2

I've started with...

Code:
awk '{a[d++]=$1}END{for(i=1;i<=d;i++){ if ( a[i] < 3 ) print a[i] }}' < file1

...so basically I'm stuck with step 2) already.

Could you set me on the right track?

Last edited by radoulov; 06-06-2011 at 10:46 AM.. Reason: Code tags.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Referencing a range of parameters?

I can't seem to find anywhere how to syntactically reference a range of parameters in the script I am trying to write. My script requires at least 2 parameters to run, with parameter 1 being the main file, which I want appended to x amount of target files, which will be parameters 2 through... (4 Replies)
Discussion started by: Relykk
4 Replies

2. Shell Programming and Scripting

Referencing variables in commands

The script I am writing must be able to run several commands (tar, gzip etc) on filenames that are supplied by variables. I am unsure as to what syntax is required/ideal when referencing variables in filenames. The following is a sample command that I would like the script to execute: tar cvf... (3 Replies)
Discussion started by: mharley
3 Replies

3. Shell Programming and Scripting

files cross over

I have many files (File 1, File 2, File 3, ...) in same directory. The format of all these files are same. What I would like to do is to combine all these files into a single file via cross over. Example) >>File 1 look like this. f1 01 1.0 f1 02 2.0 f1 03 3.0 f1 04 4.0 f1 05 5.0 f1 06... (2 Replies)
Discussion started by: Jae
2 Replies

4. Programming

Symbol referencing error

Hey everyone, I can't figure out this symbol referencing error after looking at it for the longest time, and I figured some fresh eyes might be able to point something out I am overlooking. Undefined first referenced symbol in... (1 Reply)
Discussion started by: fromatz
1 Replies

5. Shell Programming and Scripting

Variable Referencing

I am referencing variables in the following way var1="greeting" greeting="Welcome!" How do I echo var1 in such a way that it outputs Welcome! ? (3 Replies)
Discussion started by: milo7
3 Replies

6. Shell Programming and Scripting

Cross checking two files

i have two files which contains some fields separated by columns as 03/29/1999 08:48:12 02 172.16.114.50 03/29/1999 09:08:00 480 172.16.112.100 Both of the files do have the same format I want the script which will take two such... (3 Replies)
Discussion started by: vaibhavkorde
3 Replies

7. UNIX for Dummies Questions & Answers

Cross complie linux make files onto a windows 7 machine using PGI Cygwin

Hello, I am very unfamiliar with linux/unix (don't even know the difference), but am trying to get some linux software to run on my Windows machine for my research. I have the makefiles for the software, and it is designed to be compiled in the PGI complier, which I also have. When i... (6 Replies)
Discussion started by: roba87
6 Replies

8. Shell Programming and Scripting

Referencing file for values and referencing another file to replace values

Hi I have a file which has values in each line: MP304,d40000 MP310,ff0000 etc I have another file which as the first value in it and is unique in the file(not repeated). I need to replace a string with the second value above. The second file contents is as follows:(snippet) <g ... (12 Replies)
Discussion started by: majikins
12 Replies

9. Shell Programming and Scripting

Dynamically referencing a Path

How would I reference a source path (where I have a script pulling data from) that changes location? For example, a Mail folder is being used as a source to pull some data, but somebody could move the folder around in the GUI of Mail, changing it's location in the filesystem (that I am referencing... (11 Replies)
Discussion started by: sudo
11 Replies
SOL(6)								   Games Manual 							    SOL(6)

NAME
AisleRiot - a collection of card games which are easy to play with the aid of a mouse. SYNOPSIS
sol [options] DESCRIPTION
This manual page documents briefly the sol command. For more information, please refer to the excellent GNOME help for AisleRiot AisleRiot (also known as Solitaire or sol) is a collection of card games which are easy to play with the aid of a mouse. The rules for the games have been coded for your pleasure in the GNOME scripting language (Scheme). It is part of the gnome-games package. The following games can be selected from within the program, or by using a command line switch: Peek, Auld Lang Syne, Fortunes, Seahaven, King Albert, First Law, Straight Up, Jumbo, Accordion, Ten Across, Plait, Lady Jane, Gypsy, Neighbor, Jamestown, Osmosis, Kings Audience, Glenwood, Gay Gordons, Monte Carlo, Kansas, Camelot, Fourteen, Scorpion, Isabel, Escalator, Agnes, Bristol, Quatorze, Bear River, Gold Mine, Athena, Spiderette, Chessboard, Backbone, Yukon, Union Square, Eight Off, Napoleons Tomb, Forty Thieves, Streets And Alleys, Maze, Clock, Pileon, Canfield, Thirteen, Bakers Game, Triple Peaks, Easthaven, Terrace, Aunt Mary, Carpet, Sir Tommy, Diamond Mine, Yield, Labyrinth, Thieves, Saratoga, Cruel, Block Ten, Will O The Wisp, Odessa, Eagle Wing, Treize, Zebra, Cover, Elevator, Fortress, Giant, Spider, Gaps, Bakers Dozen, Whitehead, Freecell, Hel- sinki, Spider Three Decks, Scuffle, Poker, Klondike Three Decks, Valentine, Royal East, Thumb And Pouch, Klondike, Doublets, Tem- plate, Golf, Westhaven, Beleaguered Castle, Hopscotch OPTIONS
AisleRiot accepts the following options, besides the usual Gtk+/GNOME switches: -v, --variation=NAME Select the game to play --display=DISPLAY X display to use USAGE
This text is taken verbatim from the AisleRiot Manual V2.12. Moving the cards is reasonably obvious. Assuming you have a right-handed mouse, left-click on a card and drag it somewhere. Release the mouse button to deposit the card. If a card can be moved to the foundation(s), you do not need to drag it. You can double-click on it and it will move. If a sequence of cards can be moved to the foundations, you can generally move the sequence as one move. Double clicking a card will send it to a foundation, if that is possible. This is useful for cleaning up large numbers of cards at the end of a successful game. In games which have a stock pile you can redeal it by clicking on the empty space where it was. Be warned that some games only let you do this a limited number of time. Watch for the Redeals Left message at the bottom of the window. A useful tip to know is that right-clicking on a face-up card which is partially obscured by a card laid over it will raise it so that you can see what it is. There is an alternative way to move cards. By selecting Click to move from the Control menu you can click once to pick up a card and then click again to place it. This can be faster than dragging and will be easier on your hand since you don't have to hold the mouse down. However, it may take a while to get used to. Some games have options to change the way the game is played. For example Klondike can be played with either single card deals or three- card deals. In these games there is a separate menu with the game's name. You can only change the rules of the game at the beginning of the game -- the menu will be inactive during the game. Statistics on how well you have done at a particular game are available by selecting Statistics from the Game menu. Only games where you actually start moving cards are counted. The statistics are here for your own enjoyment, there are numerous ways to cheat and it is unwise to make comparisons. HOMEPAGE
http://www.gnome.org/projects/gnome-games/ AUTHOR
This manual page was written by Martin Ferrari <martin.ferrari@gmail.com>, for the Debian system (but may be used by others). You can find the list of authors and more information about AisleRiot in /usr/share/doc/gnome-games. AisleRiot March 22, 2007 SOL(6)
All times are GMT -4. The time now is 03:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy