Sponsored Content
Top Forums Shell Programming and Scripting Help with reading two input files in awk Post 302573526 by joseamck on Monday 14th of November 2011 08:51:38 PM
Old 11-14-2011
It works
The only change I made to your code was the ">" to "<" to look like this (val<=$1)

but the code prints the values of file1 as well as a new row

example:
Code:
0.000189449
  1.8945978E-04  1.4725076E-18  1.4416145E-18  1.4723191E-18
0.00017835
  1.7836914E-04  1.6709859E-18  1.6843205E-18  1.6807697E-18
0.000176738
  1.7675308E-04  1.6943236E-18  1.7221128E-18  1.7171747E-18
0.00018811
  1.8812889E-04  1.5341278E-18  1.4887214E-18  1.5153740E-18
0.000189504
  1.8952315E-04  1.4725076E-18  1.4402210E-18  1.4723191E-18
0.000188155
  1.8816059E-04  1.5400582E-18  1.4971780E-18  1.5158510E-18
0.000180065
  1.8008027E-04  1.6634776E-18  1.6213719E-18  1.5959426E-18
0.000178991
  1.7900289E-04  1.6891735E-18  1.6462933E-18  1.6532895E-18
0.000178252
  1.7827407E-04  1.6709859E-18  1.6950919E-18  1.6897323E-18
0.000182513
  1.8252021E-04  1.6103587E-18  1.5602976E-18  1.5690959E-18


which I don't want. In {print;exit} this is the part I don't understand on how to make it only print the data from file 2.

thanks

---------- Post updated at 07:51 PM ---------- Previous update was at 07:43 PM ----------

Never mind. removing the echo works like you say previously.

Final code:
Code:
while read line
do   
    awk -v val=$line '{if (val<=$1) {print;exit}}' file2
done < file1


Thanks

Last edited by Franklin52; 11-15-2011 at 03:41 AM.. Reason: Please use code tags, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk reading 2 input files but not getting expected value

I'm reading 2 input files but not getting expected value. I should get an alpha value on file_1_data but not getting any. Please help. >cat test6.sh awk ' FILENAME==ARGV { file_1_data=$0; print "----- 1 Line " NR " -----" $1; next } FILENAME==ARGV { file_2_data=$0; print "----- 2... (1 Reply)
Discussion started by: pdtak
1 Replies

2. Shell Programming and Scripting

Reading an Input file and searching for occurrences WIHOUT SED or AWK

Hi people. I am new to shell scripting, so I need a little help. I want to create a script named that takes an argument as a file, Read the input file and look for occurrences of the current username (say abc.xyz) who is executing the script. On finding an occurrence of the username take that line... (2 Replies)
Discussion started by: kartikkumar84@g
2 Replies

3. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies

4. Shell Programming and Scripting

Reading input files

Okay, so I've looked on here and found some similar things, but not exactly what I am looking for. I am working on creating a script that can back up some files, based on the contents of another file - the configuration file. First file contains the files to back up - we'll call this... (1 Reply)
Discussion started by: pdxwarrior
1 Replies

5. Shell Programming and Scripting

Create Multiple files by reading a input file and changing the contents

Being new to this area .I have been assigned a task which i am unable to do . Can any one please help me . Hi I have requirement where i have input file XYZ_111_999_YYYYMMDD_1.TXT and with header and series of Numbers and Footer. I want to create a mutiple output files with each file having a... (2 Replies)
Discussion started by: bhargavkr
2 Replies

6. Shell Programming and Scripting

Reading from standard input with awk

Hello, Could somebody please give me an awk example on how to read from the standard input. It means as the "read" function in Korn shell. Thx in advance ... (3 Replies)
Discussion started by: rany1
3 Replies

7. Shell Programming and Scripting

awk script - reading input lines

Can I do something like, if($0==/^int.*$/) { print "Declaration" } for an input like: int a=5; If the syntax is right, it is not working for me, but I am not sure about the syntax. Please help. Thanks, Prasanna (1 Reply)
Discussion started by: prasanna1157
1 Replies

8. Shell Programming and Scripting

Perl Script Not Reading Input Files Correctly

This is one of the strangest things that's happening to me. I'm writing a new Perl script that is trying to read a file. The file is originally in .mof format, but I also saved the contents into a .txt file. As a simple test, I wrote this: #!/user/bin/perl -w use strict; ... (3 Replies)
Discussion started by: kooshi
3 Replies

9. Shell Programming and Scripting

awk- reading input file twice

Hello, I've been trying to come up with a solution for the following problem; I have an input file with two columns and I want to print as an output the first column without any changes but for the second column, I want to divide it by its last value. Example input: 1 9 2 10 3 11 4 12 5... (14 Replies)
Discussion started by: acsg
14 Replies

10. Open Source

Splitting files using awk and reading filename value from input data

I have a process that requires me to read data from huge log files and find the most recent entry on a per-user basis. The number of users may fluctuate wildly month to month, so I can't code for it with names or a set number of variables to capture the data, and the files are large so I don't... (7 Replies)
Discussion started by: rbatte1
7 Replies
Tk_GeometryRequest(3)					       Tk Library Procedures					     Tk_GeometryRequest(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_GeometryRequest, Tk_SetMinimumRequestSize, Tk_SetInternalBorder, Tk_SetInternalBorderEx - specify desired geometry or internal border for a window SYNOPSIS
#include <tk.h> Tk_GeometryRequest(tkwin, reqWidth, reqHeight) Tk_SetMinimumRequestSize(tkwin, minWidth, minHeight) Tk_SetInternalBorder(tkwin, width) Tk_SetInternalBorderEx(tkwin, left, right, top, bottom) ARGUMENTS
Tk_Window tkwin (in) Window for which geometry is being requested. int reqWidth (in) Desired width for tkwin, in pixel units. int reqHeight (in) Desired height for tkwin, in pixel units. int minWidth (in) Desired minimum requested width for tkwin, in pixel units. int minHeight (in) Desired minimum requested height for tkwin, in pixel units. int width (in) Space to leave for internal border for tkwin, in pixel units. int left (in) Space to leave for left side of internal border for tkwin, in pixel units. int right (in) Space to leave for right side of internal border for tkwin, in pixel units. int top (in) Space to leave for top side of internal border for tkwin, in pixel units. int bottom (in) Space to leave for bottom side of internal border for tkwin, in pixel units. _________________________________________________________________ DESCRIPTION
Tk_GeometryRequest is called by widget code to indicate its preference for the dimensions of a particular window. The arguments to Tk_GeometryRequest are made available to the geometry manager for the window, which then decides on the actual geometry for the window. Although geometry managers generally try to satisfy requests made to Tk_GeometryRequest, there is no guarantee that this will always be possible. Widget code should not assume that a geometry request will be satisfied until it receives a ConfigureNotify event indicating that the geometry change has occurred. Widget code should never call procedures like Tk_ResizeWindow directly. Instead, it should invoke Tk_GeometryRequest and leave the final geometry decisions to the geometry manager. If tkwin is a top-level window, then the geometry information will be passed to the window manager using the standard ICCCM protocol. Tk_SetInternalBorder is called by widget code to indicate that the widget has an internal border. This means that the widget draws a deco- rative border inside the window instead of using the standard X borders, which are external to the window's area. For example, internal borders are used to draw 3-D effects. Width specifies the width of the border in pixels. Geometry managers will use this information to avoid placing any children of tkwin overlapping the outermost width pixels of tkwin's area. Tk_SetInternalBorderEx works like Tk_SetInternalBorder but lets you specify different widths for different sides of the window. Tk_SetMinimumRequestSize is called by widget code to indicate that a geometry manager should request at least this size for the widget. This allows a widget to have some control over its size when a propagating geometry manager is used inside it. The information specified in calls to Tk_GeometryRequest, Tk_SetMinimumRequestSize, Tk_SetInternalBorder and Tk_SetInternalBorderEx can be retrieved using the macros Tk_ReqWidth, Tk_ReqHeight, Tk_MinReqWidth, Tk_MinReqHeight, Tk_MinReqWidth, Tk_InternalBorderLeft, Tk_Internal- BorderRight, Tk_InternalBorderTop and Tk_InternalBorderBottom. See the Tk_WindowId manual entry for details. KEYWORDS
geometry, request Tk 8.4 Tk_GeometryRequest(3)
All times are GMT -4. The time now is 11:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy