Sponsored Content
Full Discussion: Parsing a file in bash
Top Forums UNIX for Advanced & Expert Users Parsing a file in bash Post 302910598 by Yoda on Friday 25th of July 2014 03:09:29 PM
Old 07-25-2014
You could do it using awk alone:
Code:
awk '
        /^[0-9]/ {
                ip = $1
                next
        }
        !/^[0-9]/ {
                A[ip] = A[ip] ? A[ip] FS $2 : $2
        }
        END {
                for ( k in A )
                        print k, A[k]
        }
' ex1

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

2. Shell Programming and Scripting

Help parsing filename with bash script

Hi all! Looking for some help parsing filenames in bash. I have a directory full of files named "livingroom-110111105637.avi". The format is always date and time (yymmddhhmmss). I'm looking to parse the filenames so they are a little more easily readable. Maybe rename them to... (4 Replies)
Discussion started by: mtehonica
4 Replies

3. Shell Programming and Scripting

Parsing (Bash)

Hello, I need help. I create www page, and I have link, where is weather and is updated each hour. And I need cut only weather from source code. Example: Monday : 12/14 ... Can you help me? Thanks (2 Replies)
Discussion started by: krcek12
2 Replies

4. Shell Programming and Scripting

parsing a config file using bash

Hi , I have a config _file that has 3 columns (Id Name Value ) with many rows . In my bash script i want to be able to parse the file and do a mapping of any Id value so if i have Id of say brand1 then i can use the name (server5X) and Value (CCCC) and so on ... Id Name ... (2 Replies)
Discussion started by: nano2
2 Replies

5. Shell Programming and Scripting

Looking for help with parsing file contents in bash [newbie]

Hi I'm just messing around with bash and trying to learn it because I have a course next semester dealing with OS design where we need to know how to use SSH client and either bash or ksh. I've never done shell scripting before. I just started today and I was wondering how parsing files... (1 Reply)
Discussion started by: mehungry
1 Replies

6. Shell Programming and Scripting

BASH parsing for html tags

Hello can anyone help me parse this line. <tr><td>United States of America</td><td>Dollar</td><td>43.309</td></tr><tr><td>Japan</td><td>Yen</td><td>0.5579</td></tr> the line above did not break. so i would like to have a result like this United States of America Dollar 43.309 Japan... (3 Replies)
Discussion started by: doomsayer16
3 Replies

7. Shell Programming and Scripting

Column parsing in a bash script - HELP

I would like to setup a script that pulls in time/date in two seperate columns, and then name the other columns as listed below: Column1=Art/TJ output Column2=Art/TJ output Column3=TJ output column4=Art output Column5=If time/date past 12:00 noon -fail Colume6=If time/date before... (1 Reply)
Discussion started by: walnutpony123
1 Replies

8. Shell Programming and Scripting

Bash script not parsing file with spaces in path

Hi everyone, I'm trying to write my first ever shell script, the OS is Raspbian. The code I have written must be executed whenever a certain database has been modified. The database resides on a Windows server to which I have a mount point, and I have no control over the Windows server at all so... (2 Replies)
Discussion started by: gjws
2 Replies

9. Shell Programming and Scripting

Parsing and Editing a json file with bash script

I am trying to automate editing of a json file using bash script. The file I initially receive is { "appMap": { "URL1": { "name": "a" }, "URL2": { "name": "b" }, "URL3": { "name": "c" }, } WHat I would like to do is replace... (5 Replies)
Discussion started by: Junaid Subhani
5 Replies

10. Shell Programming and Scripting

Parsing to_addr field in bash

Hi there, I'm trying to parse the to_addr field of emails and split it into individual email addresses. The idea is to split using the comma character (,): These two first approach work: $ field="'Paul FOO' <paul@foo.com>, Andrew FOO <andrew@foo.com>" $ IFS=, read -r -a array <<< "$field";... (4 Replies)
Discussion started by: chebarbudo
4 Replies
HTML::Form(3)						User Contributed Perl Documentation					     HTML::Form(3)

NAME
HTML::Form - Class that represents HTML forms SYNOPSIS
use HTML::Form; $form = HTML::Form->parse($html, $base_uri); $form->value(query => "Perl"); use LWP; LWP::UserAgent->new->request($form->click); DESCRIPTION
Objects of the "HTML::Form" class represents a single HTML <form> ... </form> instance. A form consist of a sequence of inputs that usu- ally have names, and which can take on various values. The following methods are available: $form = HTML::Form->new($method, $action_uri, [[$enctype], $input,...]) The constructor takes a $method and a $uri as argument. The $enctype and and initial inputs are optional. You will normally use HTML::Form->parse() to create new HTML::Form objects. @forms = HTML::Form->parse($html_document, $base_uri) The parse() class method will parse an HTML document and build up "HTML::Form" objects for each <form> found. If called in scalar con- text only returns the first <form>. Returns an empty list if there are no forms to be found. The $base_uri is (usually) the URI used to access the $html_document. It is needed to resolve relative action URIs. For LWP this parameter is obtained from the $response->base() method. $form->push_input($type, \%attr) Adds a new input to the form. $form->method( [$new] ) $form->action( [$new] ) $form->enctype( [$new] ) These method can be used to get/set the corresponding attribute of the form. $form->inputs This method returns the list of inputs in the form. $form->find_input($name, $type, $no) This method is used to locate some specific input within the form. At least one of the arguments must be defined. If no matching input is found, "undef" is returned. If $name is specified, then the input must have the indicated name. If $type is specified then the input must have the specified type. In addition to the types possible for <input> HTML tags, we also have "textarea" and "option". The $no is the sequence number of the input with the indicated $name and/or $type (where 1 is the first). $form->value($name, [$value]) The value() method can be used to get/set the value of some input. If no input have the indicated name, then this method will croak. $form->try_others(&callback) This method will iterate over all permutations of unvisited enumerated values (<select>, <radio>, <checkbox>) and invoke the callback for each. The callback is passed the $form as argument. $form->make_request Will return a HTTP::Request object that reflects the current setting of the form. You might want to use the click method instead. $form->click([$name], [$x, $y]) Will click on the first clickable input ("input/submit" or "input/image"), with the indicated $name, if specified. You can optinally specify a coordinate clicked, which only makes a difference if you clicked on an image. The default coordinate is (1,1). $form->form Returns the current setting as a sequence of key/value pairs. $form->dump Returns a textual representation of the form. Mainly useful for debugging. If called in void context, then the dump is printed on STDERR. INPUTS
An "HTML::Form" contains a sequence of inputs. References to the inputs can be obtained with the $form->inputs or $form->find_input meth- ods. Once you have such a reference, then one of the following methods can be used on it: $input->type Returns the type of this input. Types are stuff like "text", "password", "hidden", "textarea", "image", "submit", "radio", "checkbox", "option"... $input->name([$new]) $input->value([$new]) These methods can be used to set/get the current name or value of an input. If the input only can take an enumerated list of values, then it is an error to try to set it to something else and the method will croak if you try. $input->possible_values Returns a list of all values that and input can take. For inputs that does not have discrete values this returns an empty list. $input->other_possible_values Returns a list of all values not tried yet. $input->form_name_value Returns a (possible empty) list of key/value pairs that should be incorporated in the form value from this input. $input->click($form, $x, $y) Some input types (currently "sumbit" buttons and "images") can be clicked to submit the form. The click() method returns the corrsponding "HTTP::Request" object. SEE ALSO
LWP, HTML::Parser, webchatpp COPYRIGHT
Copyright 1998-2000 Gisle Aas. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. libwww-perl-5.65 2001-08-01 HTML::Form(3)
All times are GMT -4. The time now is 09:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy