Sponsored Content
Top Forums Shell Programming and Scripting foreach variable used in awk (please help!!) Post 302386218 by Zoho on Monday 11th of January 2010 07:04:50 PM
Old 01-11-2010
foreach variable used in awk (please help!!)

I have a list of markers, say marker.txt:
Code:
rs913257
rs1018390
rs764180

and I need to know which ROW that each marker appears in another map file, say map.txt:
Code:
a rs12354060
b rs913257
c rs6650104
d rs2185539
e rs6681105
f rs1018390
g rs764180
h rs12564807
i rs3094315

The result shall return:
Code:
2
6
7

My marker_row.csh is like this:
Code:
#! /bin/csh -f

foreach marker (`more marker.txt`)
    awk -F, '{FS=" "; if($2==$marker) print NR}' map.txt
end

but returns me nothing!

Please help! Appreciate a lot!!

Last edited by Scott; 01-11-2010 at 08:19 PM.. Reason: Added code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to define two variable in foreach command??

Hello, I just want to know how If it's possiple to define 2 variable using foreach command ??? I have directory inside that directory around 1000 file, I want to rename all of this files to something I have it in a list. Example :- ------This is what in my directory---------- d1 d2... (14 Replies)
Discussion started by: geoquest
14 Replies

2. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

3. Shell Programming and Scripting

using awk for setting variable but change the output of this variable within awk

Hi all, Hope someone can help me out here. I have this BASH script (see below) My problem lies with the variable path. The output of the command find will give me several fields. The 9th field is the path. I want to captured that and the I want to filter this to a specific level. The... (6 Replies)
Discussion started by: Cowardly
6 Replies

4. Shell Programming and Scripting

HELP with AWK one-liner. Need to employ an If condition inside AWK to check for array variable ?

Hello experts, I'm stuck with this script for three days now. Here's what i need. I need to split a large delimited (,) file into 2 files based on the value present in the last field. Samp: Something.csv bca,adc,asdf,123,12C bca,adc,asdf,123,13C def,adc,asdf,123,12A I need this split... (6 Replies)
Discussion started by: shell_boy23
6 Replies

5. Shell Programming and Scripting

Passing awk variable argument to a script which is being called inside awk

consider the script below sh /opt/hqe/hqapi1-client-5.0.0/bin/hqapi.sh alert list --host=localhost --port=7443 --user=hqadmin --password=hqadmin --secure=true >/tmp/alerts.xml awk -F'' '{for(i=1;i<=NF;i++){ if($i=="Alert id") { if(id!="") if(dt!=""){ cmd="sh someScript.sh... (2 Replies)
Discussion started by: vivek d r
2 Replies

6. Shell Programming and Scripting

awk print variable then fields in variable

i have this variable: varT="1--2--3--5" i want to use awk to print field 3 from this variable. i dont want to do the "echo $varT". but here's my awk code: awk -v valA="$varT" "BEGIN {print valA}" this prints the entire line. i feel like i'm so close to getting what i want. i... (4 Replies)
Discussion started by: SkySmart
4 Replies

7. Shell Programming and Scripting

Comparing 2 variable in a list with foreach

cat file1 a b c d e f this is what is in my script foreach i (`cat file1`) foreach j (`cat file1`) #do something here end end basically i want to compare ab, ac, ad, ae, af, ba, bc, bd, be.... and also skipping aa,bb if possible.. if that anyway for me to just use 1 foreach? (2 Replies)
Discussion started by: ctphua
2 Replies

8. UNIX for Dummies Questions & Answers

Reading foreach variable from a text file

Hello, I have a text file named "foreach.txt" which reads like --- foreach cal ( 1 2 3 4 5 ) I am using a simple script which looks like --- #!/bin/tcsh foreach cal (1 2 3 4 5) echo "$cal" end Is it possible to modify the script in such a way that instead of writing foreach cal (1... (6 Replies)
Discussion started by: Indra2011
6 Replies

9. UNIX for Beginners Questions & Answers

How can I assign awk's variable to shell script's variable?

I have the following script, and I want to assign the output ($10 and $5) from awk to N and L: grdinfo data.grd | awk '{print $10,$5}'| read N L output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies

10. UNIX for Beginners Questions & Answers

Grepping for one variable while using awk to parse an associated variable

Im trying to search for a single variable in the first field and from that output use awk to extract out the lines that contain a value less than a value stored in another variable. Both the variables are associated with each other. Any guidance is appreciated. File that contains the... (6 Replies)
Discussion started by: ncwxpanther
6 Replies
REPLMARKS(1)						      General Commands Manual						      REPLMARKS(1)

NAME
       replmarks - replace triangular markers in a RADIANCE scene description

SYNOPSIS
       replmarks [ -e ][ -m newmod ][ -s scale ] { -x objfile | -i octree | -I mesh } modname ..  [ file ..  ]

DESCRIPTION
       Replmarks  replaces triangular markers identified by the modifier modname in each scene description file and writes the result to the stan-
       dard output.  The -x option indicates that each marker should be replaced by an appropriate xform(1) command on	objfile.   The	-i  option
       indicates  that each marker should be replaced by an instance of octree.  The -I option indicates that each marker should be replaced by an
       instance of the Radiance mesh mesh.  One of these three options must appear on the command line, along with modname, the modifier  used	by
       markers in the file.

       Multiple modifiers may be given, as long as each one is preceded by its own -x or -i option.

       The  transformation  for  each  marker  is determined by its location and orientation.  A marker should be a right triangle pointing like a
       half-arrow in the direction of the transformed x-axis, x'.  The longest side is the hypoteneuse, the second longest side  is  the  x'-axis,
       and  the  third longest side indicates the direction of the y'-axis.  Any additional sides will be ignored (ie. a quadrilateral may be used
       instead of a triangle if the extra side is small).  The z'-axis is determined by the cross product of the x' and y' axes, and the origin is
       the common vertex between x' and y'.

       The  size  of  the marker is ignored unless the -s option is used, where scale is a multiplier for the x'-axis length to indicate the total
       scale factor.  For example, a scale value of 5 with a marker length of .5 would result in a total scale factor of 2.5 to  be  used  in  the
       transformation.

       The  -e	option	causes commands in the file to be expanded, and is required to replace markers from commands in the input file.  Even with
       this option, replmarks will not examine objects for markers.  Specifically, an object included by replmarks as a result of a  -x  expansion
       will  be  transferred  verbatim,  without  regard to any surfaces therein that might have been considered as marks if they were on the main
       input.

       The -m option causes all replaced objects to be given the modifier newmod.  Otherwise, the new object surfaces will  use  their	originally
       defined	modifiers.   A	different replacement modifier may be given for each marker type.  The marker modifier name itself is only used to
       identify markers, and will not appear in the output in any form.

       If no input file is given, the standard input is read.

EXAMPLE
       To replace all polygons with the modifier ``knobs'' in the file input with a transformed ``knob.rad'' and write the result to output:

	 replmarks -x knob.rad knobs input > output

       To use instances of ``tree.oct'' with scaling set to three times the tree marker length:

	 replmarks -s 3 -i tree.oct tree input > output

AUTHOR
       Greg Ward

SEE ALSO
       arch2rad(1), ies2rad(1), xform(1)

RADIANCE							      3/24/94							      REPLMARKS(1)
All times are GMT -4. The time now is 02:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy