Sponsored Content
Full Discussion: args of 50+ files
Top Forums UNIX for Dummies Questions & Answers args of 50+ files Post 302260467 by bakunin on Thursday 20th of November 2008 03:14:37 PM
Old 11-20-2008
Quote:
Originally Posted by lost
What is it I do wrong?
Code:
ls *contacts | while $file ; do 
     awk '{printf ($2 in a) ? ","$5 : (NR>1) ? RS $2 FS $5 : $2 FS $5; a[$2]} END{print e}' $file 
done

The prolem is in the first line: sustitute "file" for "$file$ and add a "read", which is a keyword. See my example above. The first line schould be

"ls *contacts | while read file ; do"

and the variable "file" will hold one value after the other in each cycle of the loop. The following example is to make it better understandable:

Code:
ls *contacts | while read myvar ; do
     echo "===== $myvar ====="
done

Compare the output of this to the output of "ls -1 *contacts". You will notice that "myvar" gets filled with one value after the other in the loop as you can see when it is used in the echo-statement.

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Args to Array

Hello all, I have a question. Please help me to populate an array with the arguments passing to a Shell scripts. For example when I call "abc.sh a1 a2 a3" args (a1, a2, ...) recieved in an Array inside the abc.sh arr = a1 arr = a2 and so on... Thanks in advance, (2 Replies)
Discussion started by: Shaz
2 Replies

2. UNIX for Dummies Questions & Answers

alias with args how to ...

Hello ( sorry newbie question ) I don't understand something im trying to make simple alias that takes 1 arg but it don't gives me the desire result here is what I have : stlist | awk '{print "ls -l "$2}' now I want to translate it to alias that takes instead of the $2 one arg so I did : ... (4 Replies)
Discussion started by: umen
4 Replies

3. Programming

Command line args

My program usage takes the form for example; $ theApp 2 "one or more words" i.e. 3 command line arguments; application name, an integer, some text My code includes the following 4 lines: int anInteger; char words; sscanf(argv, "%d", &anInteger); sscanf(argv, "%s", &message); Based... (2 Replies)
Discussion started by: enuenu
2 Replies

4. UNIX for Dummies Questions & Answers

command line args

I am trying to print command line arguments one per second. I have this while do echo "6" shift echo "5" shift echo "4" shift echo "3" shift echo "2" shift echo "1" shift done (2 Replies)
Discussion started by: skooly5
2 Replies

5. UNIX for Dummies Questions & Answers

command line args 2

I have this while loop and at the end I am trying to get it to tell me the last argument I entered. And with it like this all I get is the sentence with no value for $1. Now I tried moving done after the sentence and it printed the value of $1 after every number. I don't want that I just want... (2 Replies)
Discussion started by: skooly5
2 Replies

6. UNIX for Dummies Questions & Answers

Parameters/Args

Hello, i have a problem. I must write a script, which wants 2 arguments. for example: ./test.sh x.txt y.txtit must be write x.txt in y.txt and when i give 1 or no argument like /.test.sh x.txtmust this give a error message like: SYNTAX <inputfile> <outputfile> my solution is... (5 Replies)
Discussion started by: eightball
5 Replies

7. Shell Programming and Scripting

For Args and Nawk

I am trying to write a simple shell script that will take certain arguments (numerical values) and plug each one into a nawk command. I thought I would need to use for args x y z but i get syntax errors: for args 16 1 3 25 31 41 do nawk -F, '{if($10==$ &&... (8 Replies)
Discussion started by: he204035
8 Replies

8. Shell Programming and Scripting

Store args passed in array but not the first 2 args

Store args passed in array but not the first 2 args. # bash declare -a arr=("$@") s=$(IFS=, eval 'echo "${arr}"') echo "$s" output: sh array.sh 1 2 3 4 5 6 1,2,3,4,5,6 Desired output: sh array.sh 1 2 3 4 5 6 3,4,5,6 (2 Replies)
Discussion started by: iaav
2 Replies

9. Shell Programming and Scripting

Problem parsing args

Heya Tooltip: Parsing (getopts) for -u successfully sets mode=umnt, but case umnt is not executed, instead it either executes/show help or regular mount screen. I had copy pasted the structure of a getopts 'structure' from Man Page for getopts (posix Section 1) - The UNIX and Linux Forums... (1 Reply)
Discussion started by: sea
1 Replies

10. UNIX for Dummies Questions & Answers

Edit $args within a command

Hi, I'm using a while loop for a given command "bowtie2" with several parameters. mkdir clean paste <(ls --quote-name ./qc/sg_*_R1_val_1.fq.gz) <(ls --quote-name ./qc/sg_*_R2_val_2.fq.gz) |sed 's/"./-1 ./' | sed 's/gz"\t/gz\t -2 /' | sed 's/"//g' |\ while read args ; do ... (5 Replies)
Discussion started by: sargotrons
5 Replies
xpaaccess(1)							SAORD Documentation						      xpaaccess(1)

NAME
xpaaccess - see if template matches registered XPA access points SYNOPSIS
xpaaccess [-c] [-h] [-i nsinet] [-m method] [-n] [-t sval,lval] [-u users] -v <template> [type] OPTIONS
-c contact each access point individually -h print help message -i access XPA point on different machine (override XPA_NSINET) -m override XPA_METHOD environment variable -n return number of matches instead of "yes" or "no" -t [s,l] set short and long timeouts (override XPA_[SHORT,LONG]_TIMEOUT) -u [users] XPA points can be from specified users (override XPA_NSUSERS) -v print info about each successful access point -V print info or error about each access point --version display version and exit DESCRIPTION
xpaaccess returns "yes" to stdout (with a return error code if 1) if there are existing XPA access points that match the template (and optional access type: g,i,s). Otherwise, it returns "no" (with a return error code of 0). If -n is specified, the number of matches is returned instead (both to stdout and in the returned error code). If -v is specified, each access point is displayed to stdout instead of the number of matches. By default, xpaaccess simply contacts the xpans name server to find the list of registered access points that match the specified template. It also checks to make sure the specified types are supported by that access point. This is the fastest way to determine available access points. However, an access point might registered but not yet available, if, for example, the server program has not entered its event loop to process XPA requests. To find access points that are guaranteed to be available for processing, use the -c (contact) switch. With this switch, xpaaccess contacts each matching XPA server (rather than the name server) to make sure the registered access point really is ready for processing. In this mode, if an access point is registered but not available, xpaaccess will pause for a period of time equal to the XPA_LONG_TIMEOUT, in order to give the server a chance to ready itself. By default, this timeout is 30 seconds. You can shorten the time of delay using the -t "short,long" switch. For example, to shorten the delay time to 2 seconds, use: xpaaccess -c -t "2,2" ds9 The first argument is the short delay value, and is ignored in this operation. The second is the long delay timeout. Note also that the default xpaaccess method (no -c switch) does not check access control (acls) but rather only checks whether the access point is both registered with the xpans name server and provides the specified type of access. In other words, the default xpaaccess could return 'yes' when you might not actually have access. This mode also always returns 'yes' for the xpans name server itself, regardless of whether the name server is active. The -c (contact) switch, which contacts the access point directly, can and does check the access con- trol (only for servers using version 2.1 and above) and also returns the real status of xpans. SEE ALSO
See xpa(7) for a list of XPA help pages version 2.1.14 June 7, 2012 xpaaccess(1)
All times are GMT -4. The time now is 03:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy