Sponsored Content
Top Forums Shell Programming and Scripting awk reading 2 input files but not getting expected value Post 302190504 by pdtak on Tuesday 29th of April 2008 09:14:33 PM
Old 04-29-2008
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[1] { file_1_data[$1]=$0; print "----- 1 Line " NR " -----" $1; next }
FILENAME==ARGV[2] { file_2_data[$1]=$0; print "----- 2 Line " NR " -----" $1; next }
END {
# do actual data processing here
print "----- Line " NR " -----"
print "----- file_1_data[1] " file_1_data[1]
print "----- file_1_data[2] " file_1_data[2]
print "----- file_1_data[3] " file_1_data[3]
print "----- file_1_data[4] " file_1_data[4]
print "----- file_1_data[5] " file_1_data[5]
print "----- file_1_data[6] " file_1_data[6]
print "----- file_1_data[7] " file_1_data[7]
print "----- file_1_data[8] " file_1_data[8]
print "----- file_1_data[9] " file_1_data[9]
print "----- file_1_data[10] " file_1_data[10]
print "----- file_2_data[1] " file_2_data[1]
print "----- file_2_data[2] " file_2_data[2]
print "----- file_2_data[3] " file_2_data[3]
print "----- file_2_data[4] " file_2_data[4]
print "----- file_2_data[5] " file_2_data[5]
print "----- file_2_data[6] " file_2_data[6]
print "----- file_2_data[7] " file_2_data[7]
print "----- file_2_data[8] " file_2_data[8]
print "----- file_2_data[9] " file_2_data[9]
print "----- file_2_data[10] " file_2_data[10]
print "\n"
}
' infile1 infile2

>cat infile1
A
B
C
D
E
F
G
H
I
J

>cat infile2
1
2
3
4
5
6
7
8
9
10

>./test6.sh
----- 1 Line 1 -----A
----- 1 Line 2 -----B
----- 1 Line 3 -----C
----- 1 Line 4 -----D
----- 1 Line 5 -----E
----- 1 Line 6 -----F
----- 1 Line 7 -----G
----- 1 Line 8 -----H
----- 1 Line 9 -----I
----- 1 Line 10 -----J
----- 2 Line 11 -----1
----- 2 Line 12 -----2
----- 2 Line 13 -----3
----- 2 Line 14 -----4
----- 2 Line 15 -----5
----- 2 Line 16 -----6
----- 2 Line 17 -----7
----- 2 Line 18 -----8
----- 2 Line 19 -----9
----- 2 Line 20 -----10
----- Line 20 -----
----- file_1_data[1]
----- file_1_data[2]
----- file_1_data[3]
----- file_1_data[4]
----- file_1_data[5]
----- file_1_data[6]
----- file_1_data[7]
----- file_1_data[8]
----- file_1_data[9]
----- file_1_data[10]
----- file_2_data[1] 1
----- file_2_data[2] 2
----- file_2_data[3] 3
----- file_2_data[4] 4
----- file_2_data[5] 5
----- file_2_data[6] 6
----- file_2_data[7] 7
----- file_2_data[8] 8
----- file_2_data[9] 9
----- file_2_data[10] 10
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. Shell Programming and Scripting

Help with reading two input files in awk

Hello, I'm trying to write an awk program that reads two files inputs. example, file 1: 0.00017835 0.000176738 0.00018811 0.000189504 0.000188155 0.000180065 0.000178991 0.000178252 0.000182513 file 2: 1.7871769E-05 1.5139576E-16 1.5140196E-16 1.5139874E-16 1.7827407E-04 ... (5 Replies)
Discussion started by: joseamck
5 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
ipentry(n)						    An IP address entry widget							ipentry(n)

__________________________________________________________________________________________________________________________________________________

NAME
ipentry - An IP address entry widget SYNOPSIS
package require Tcl 8.4 package require Tk 8.4 package require ipentry ?0.3? ::ipentry::ipentry pathName ?option value...? ::ipentry::ipentry6 pathName ?option value...? pathName complete pathName get pathName insert iplist pathName icursor index pathName configure option value... pathName cget option _________________________________________________________________ DESCRIPTION
This package provides a widget for the entering of a IP address. ::ipentry::ipentry pathName ?option value...? Creates a new IPv4 ipentry widget and configures it with the given options and their values. ::ipentry::ipentry6 pathName ?option value...? Creates a new ipentry widget for the entry of an IPv6 address. All options are the same as the IPv4 widget. Each widget created with the command above supports the following methods: pathName complete Returns a boolean value. True indicates that the entry contains a complete IP address, meaning all fields have a value. In some cases IPv6 address are valid when fields are missing. You will need to do your own validation to detect this. pathName get Returns the contents of the entry as a list consisting of 4 or 8 elements. pathName insert iplist IPv4 Takes a list of 4 elements and inserts one into each quad of the entry, in order. All values in the list must be empty or integers. Values outside the range 0 to 255 are modified to be within the range. IPv6 Takes a list of 8 elements and inserts one into each quad of the entry, in order. All values in the list must be empty or 1 to 4 hex digits. pathName icursor index Sets the position of the widgets insertion cursor. Only integer values between 0 and 15 are valid for ipentry and 0 to 31 for ipen- try6. Setting the icursor will only have an effect if the widget already has the input focus. pathName configure option value... Modifies the configuration of the widget. For options and their meaning see the widget options section. pathName cget option Returns information about the current configuration of the widget, for the specified option. For options and their meaning see the widget options section. WIDGET OPTIONS
Command-Line Switch: -textvariable Database Name: textvariable Database Class: Variable The name of a variable which holds the value of the IP address. The value must be a string of the form NNN.NNN.NNN.NNN for IPv4 or HHHH:HHHH:HHHH:HHHH:HHHH:HHHH:HHHH:HHHH for IPv6 where H is a hex digit. The variable will be modified to represent a valid IP address if it is not already. Command-Line Switch: -state Database Name: state Database Class: State Specifies one of three states for the entry: normal, disabled, or readonly. Command-Line Switch: -font Database Name: font Database Class: Font Command-Line Switch: -bd Database Name: borderWidth Database Class: BorderWidth Command-Line Switch: -fg Database Name: foreground Database Class: Foreground Command-Line Switch: -bg Database Name: background Database Class: Background Command-Line Switch: -relief Database Name: relief Database Class: Relief Command-Line Switch: -highlightthickness Database Name: highlightThickness Database Class: HighlightThickness Command-Line Switch: -highlightcolor Database Name: highlightColor Database Class: HighlightColor Command-Line Switch: -highlightbackground Database Name: highlightBackground Database Class: HighlightBackground Command-Line Switch: -selectbackground Database Name: selectBackground Database Class: Background Command-Line Switch: -selectforeground Database Name: selectForeground Database Class: Foreground Command-Line Switch: -selectborderwidth Database Name: selectBorderWidth Database Class: BorderWidth Command-Line Switch: -disabledbackground Database Name: disabledBackground Database Class: DisabledBackground Command-Line Switch: -disabledforeground Database Name: disabledForeground Database Class: DisabledForeground Command-Line Switch: -readonlybackground Database Name: readonlyBackground Database Class: ReadonlyBackground Command-Line Switch: -insertbackground Database Name: insertBackground Database Class: Background Standard widget options. See options for a description of their meanings and values. KEYWORDS
entry, ip address ipentry 0.3 ipentry(n)
All times are GMT -4. The time now is 08:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy