Sponsored Content
Full Discussion: Basic awk help
Top Forums UNIX for Dummies Questions & Answers Basic awk help Post 302774899 by Don Cragun on Sunday 3rd of March 2013 07:26:39 PM
Old 03-03-2013
This seems to do what you want:
Code:
awk -F ': *' '
function p(){
        if(host=="")return
        printf("%s\t%s\t%s\n",node,host,agent)
        host=agent=""
}
/^T /{p();node=$2;sub(/.* /,"",node)}
$1=="Host"{host=$2}
$1=="User-Agent"{agent=$2}
END{p()}'

You can switch the order of the operands to the printf call in function p if you want the output fields in a different order.

Given the two data samples from your last message, the output produced is:
Code:
70.37.131.11	udc.msn.com.	Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0).
4.59.125.171	www.unix.com.	Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22.

 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk basic issue

Hi all, I have an awk basic question. file.text Our Location: Our home has light yellow siding, and is a duplex on Main Street, across from the High School, and across the lane from the Health Center If I run: cat file.txt | awk '{print $2}' | grep... (7 Replies)
Discussion started by: research3
7 Replies

2. UNIX for Dummies Questions & Answers

Basic awk question...getting awk to act on $1 of the command itself

I have a script problem that I am not able to solve due my very limited understanding of unix/awk. This is the contents of test.sh awk '{print $1}' From the prompt if I enter: ./test.sh Hello World I would expect to see "Hello" but all I get is a blank line. Only then if I enter "Hello... (2 Replies)
Discussion started by: JasonHamm
2 Replies

3. Shell Programming and Scripting

basic awk questions

I find an script with awk sitting around. I went through some online manuals, but I can't figure out exactly how it works. I can't post the whole program. Not allowed. This is the line that is confusing me. I get when else is in the script grep -v "^REM " $1| grep -v "JUNK;" | awk -F" "... (2 Replies)
Discussion started by: guessingo
2 Replies

4. Shell Programming and Scripting

Issue with basic Awk script

Here's a basic awk program I am trying to run. It shows no error but shows no result either too. If someone can look up and tell me what's wrong I will be obliged. Thanks. :) Code Snippet. #!/bin/bash awk '{ for (i = 1 ; i <= 3 ; i++) for ( j = 1 ; j <= 3 ; j++ ) { ... (2 Replies)
Discussion started by: mr.amitkc
2 Replies

5. UNIX for Dummies Questions & Answers

Basic loop awk/shell script question..

Hi, Sorry if this is a newbie question. I guess you can use either awk or shell script for this sequence of operations, but knowing very little about either of them I'm not sure how I should try to write this. The basic objective is to copy certain files that are scattered all over my... (10 Replies)
Discussion started by: pc2001
10 Replies

6. UNIX for Dummies Questions & Answers

Basic awk...newbie quetion

Hi, I was trying to change the value of the 4th column (put '1' in the 4th column of each row). My awk command is: awk -F, '{$3=1;}1' OFS= input.txt > ./test_out.txt My input file is: a 1 2 31 b 4 5 61 c 7 8 91 My output file (test_out.txt)is: a 1 2 31 b 4 5 61 c 7 8 91 What... (4 Replies)
Discussion started by: pc2001
4 Replies

7. UNIX for Dummies Questions & Answers

Basic arithmetic operation with awk?

input: Name|Operation rec_10|1+2+2- Output: rec_10|1 Basically I am trying to calculate the result of "the path" in $3 where the operators follow the number and not preceding them like we normally do: rec_10: +1+2-2=1 But I realise (I am sure there is a good reason for that) that awk... (7 Replies)
Discussion started by: beca123456
7 Replies

8. Shell Programming and Scripting

Confusing of some basic awk

1. increase file space first, double space a file: awk '1;{print ""}' I probably can understand it:print a blank line every time.But when I read triple space a file I am confused: awk '1;{print "\n"}' doesn't it meaning print a blank line every time too? 2. number each line of file, but... (6 Replies)
Discussion started by: hhdzhu
6 Replies
load(8) 						      System Manager's Manual							   load(8)

Name
       load - down-line load software to a target node

Syntax
       /etc/load [ node ]

Description
       The command loads software to an unattended target node.  The target node is loaded by the host that executes the command.

       The  command requires the identification of the service circuit over which the load is performed, the Ethernet hardware address of the tar-
       get node, and the service password needed to gain access to the target.	This information is included in the nodes database entry  for  the
       target  node.   A node entry is defined with the command.  For further information, see The node is the name or address of the target node.
       A node name consists of from one to six alphanumeric characters.  For single networks,  a  node	address  consists  of  a  decimal  integer
       (1-1023).   For	multiple  networks,  a	node  address  consist of two decimal integers (n.n), where the first indicates the network number
       (1-63), and the second indicates the node address (1-1023).

Options
       -p   Uses the specified service and password (next arguments) in accessing the target node.  You can omit a target node's service and pass-
	    word from the nodes database for security reasons, but you must then specify the service and password in the command line by using the
	    option.

Examples
       # /etc/load bangor -p 130fe
       This command causes node to be loaded by the ULTRIX host node executing the command.  The ULTRIX host uses the load files specified in  the
       nodes database entry for node to perform the load.

See Also
       addnode(8), ccr(8), getnode(8), mop_mom(8), remnode(8), trigger(8)
       Guide to Local Area Transport Servers

																	   load(8)
All times are GMT -4. The time now is 03:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy