Sponsored Content
Top Forums Shell Programming and Scripting [awk] - how to insert an external variable Post 302576890 by vgersh99 on Sunday 27th of November 2011 10:05:38 AM
Old 11-27-2011
Code:
for i in x86_64 i686; do
     awk -v myI="${i}" '{ print $1, $4, $5, myI }'awk $file-$i > processed-$i.log 
done

This User Gave Thanks to vgersh99 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk help (external variable)

i need help with an awk question. i am looking to have an external variable be defined outside of awk but used in awk. so if we have fields $1, $2, $3 so on and so forth, i would like to be able to dictate what field is being printed by something like $. so if i had a counter called test, make it 3... (8 Replies)
Discussion started by: pupp
8 Replies

2. Shell Programming and Scripting

If statement in awk with external variable

So I have a if statement inside an awk to check if $2 of a awk equals a specific IP but the test fails. So here is what I have. # !/bin/sh echo "Enter client ID" read ID echo "Enter month (01, 02, 03)" read month echo "Enter day (03, 15)" read day echo "Enter Year (07, 08)" read... (6 Replies)
Discussion started by: doublejz
6 Replies

3. Shell Programming and Scripting

Insert external variable in a AWK pattern

Dear all, ¿How can i insert a variable in a AWK pattern? I have almost succeeded in solving a puzzle with AWK but now i want to make a script. Let me explain. cat file.txt | awk 'BEGIN {RS="\\n\\n"} /tux/ { print "\n"$0 }' I know that this command makes right what i want to do, but mi... (8 Replies)
Discussion started by: antuan
8 Replies

4. UNIX for Dummies Questions & Answers

insert variable into awk

I'm trying to insert a filename into awk. filename="12345.wmv" I have tried this: awk '/$filename/{print $0}' infile and this: awk -v fn=$filename '/$fn/{print $0}' infile How do I insert the variable into awk? (1 Reply)
Discussion started by: locoroco
1 Replies

5. Shell Programming and Scripting

using an awk internal variable as parameter for an external array

Hello, I am running a bash script under linux which first defines an CA-array like j=0 num1=120.00 num2=10.00 until do CA='echo $num1 + $j*$num2' j=$ done within the later awk section of this same script I want to read data from a file. If the value of the second column is... (3 Replies)
Discussion started by: MotAah
3 Replies

6. Shell Programming and Scripting

Help needed with awk external variable

I'm trying to get the universities result data into different file, where the $9 contains unversity field and field7,4 & 5 contains the keys to sort the students by marks. How to use uni variable to match against $9 inside awk? c=0 for uni in `cat /tmp/global_rank| awk -F ',' '{print... (1 Reply)
Discussion started by: InduInduIndu
1 Replies

7. Shell Programming and Scripting

Insert query with shell variable with AWK

Hi, I'm a first timer with Unix so pardon my ignorance. I'm trying to read a comma separated file from the same folder where the script is and insert the value in a DB2 table. I'm using AWK for the same. I'm getting `)' not expected error. I'm not sure but for me it doesn't look like detailed... (8 Replies)
Discussion started by: Kabira Speaking
8 Replies

8. Shell Programming and Scripting

Passing external variable to awk

Hi, I am trying to write a bash script in which I need to pass a external variable to the awk program. I tired using -v but it not accepting the value. Here is my sample code. #!/usr/bin/bash ###################################################################################### ####... (5 Replies)
Discussion started by: jpkumar10
5 Replies

9. Shell Programming and Scripting

awk - saving results of external script to variable.

So, I've been playing with speeding up some analysis we do by using multiple threads of awk (actually, mawk, but code-compatible as far as I use it) on multiple CPU cores. So, I have a big data file and I have several copies of exactly the same processor script, written in mawk. I also have a... (8 Replies)
Discussion started by: treesloth
8 Replies

10. Shell Programming and Scripting

Vi / vim - Insert a external command response

I would like to execute and external command and insert it into a particular area of the file I am editing. Note that I have the ORIGINAL AT&T vi training doc dated 1987. Doesnt explain it. As an example, in a vi editor I have I would like the result : After executing the following... (1 Reply)
Discussion started by: popeye
1 Replies
xpamainloop(3)							SAORD Documentation						    xpamainloop(3)

NAME
XPAMainLoop - optional main loop for XPA SYNOPSIS
#include <xpa.h> void XPAMainLoop(); DESCRIPTION
Once XPA access points have been defined, a program must enter an event loop to watch for requests from external programs. This can be done in a variety of ways, depending on whether the event loop is processing events other than XPA events. In cases where there are no non-XPA events to be processed, the program can simply call the XPAMainLoop() event loop. This loop is implemented essentially as follows (error checking is simplified in this example): FD_ZERO(&readfds); while( XPAAddSelect(NULL, &readfds) ){ if( sgot = select(swidth, &readfds, NULL, NULL, NULL) >0 ) XPAProcessSelect(&readfds, 0); else break; FD_ZERO(&readfds); } The XPAAddSelect() routine sets up the select() readfds variable so that select() will wait for I/O on all the active XPA channels. It returns the number of XPAs that are active; the loop will end when there are no active XPAs. The standard select() routine is called to wait for an external I/O request. Since no timeout struct is passed in argument 5, the select() call hangs until there is an external request. When an external I/O request is made, the XPAProcessSelect() routine is executed to process the pending requests. In this rou- tine, the maxreq value determines how many requests will be processed: if maxreq <=0, then all currently pending requests will be pro- cessed. Otherwise, up to maxreq requests will be processed. (The most usual values for maxreq is 0 to process all requests.) If a program has its own Unix select() loop, then XPA access points can be added to it by using a variation of the standard XPAMainLoop: XPAAddSelect(xpa, &readfds); [app-specific ...] if( select(width, &readfds, ...) ){ XPAProcessSelect(&readfds, maxreq); [app-specific ...] FD_ZERO(&readfds); } XPAAddSelect() is called before select() to add the access points. If the first argument is NULL, then all active XPA access points are added. Otherwise only the specified access point is added. After select() is called, the XPAProcessSelect() routine can be called to process XPA requests. Once again, the maxreq value determines how many requests will be processed: if maxreq <=0, then all currently pend- ing requests will be processed. Otherwise, up to maxreq requests will be processed. XPA access points can be added to Xt event loops (using XtAppMainLoop()) and Tcl/Tk event loops (using vwait and the Tk loop). When using XPA with these event loops, you only need to call: int XPAXtAddInput(XtAppContext app, XPA xpa) or int XPATclAddInput(XPA xpa) respectively before entering the loop. SEE ALSO
See xpa(7) for a list of XPA help pages version 2.1.14 June 7, 2012 xpamainloop(3)
All times are GMT -4. The time now is 09:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy