The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What the command to find out the record length of a fixed length file? tranq01 UNIX for Dummies Questions & Answers 9 12-04-2008 04:04 PM
Debian: New yarssr packages fix arbitrary shell command iBot Security Advisories (RSS) 0 01-28-2008 10:20 AM
what is the maximum length of th os-command line in Unix. kumardesai UNIX for Dummies Questions & Answers 2 11-28-2007 07:37 AM
How do you take in variables/parameters from the command line? avisram UNIX for Dummies Questions & Answers 1 07-21-2005 09:47 AM
passing command line parameters to functions - sh vino Shell Programming and Scripting 5 03-05-2005 05:51 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-19-2007
cmcnorgan cmcnorgan is offline
Registered User
  
 

Join Date: Nov 2007
Location: London, Ontario, Canada
Posts: 2
Building command line parameters of arbitrary length

I couldn't find an existing thread that addressed this question, so hopefully this isn't redundant with anything previously posted. Here goes:

I am writing a C-Shell script that runs a program that takes an arbitrary number of parameters:

myprog -a file1 \
-b file2 \
-c file3 ... \
-n fileN \
-operation "a+b+c+...+n"


The files on which myprog operates are in subdirectories: 01/01.ext, 02/02.ext, ... etc.

Since the filenames happen to match the directory names, I would like to be able to pass the script an arbitrary number of directories (in practice, there will be fewer than 26, so there is no concern with running out of "-x" tags). The script would then construct the argument list for myprog so that
myscript.sh 01 02 03 ... 12
would expand into:
myprog -a 01/01.ext -b 02/02.ext ... -k 11/11.ext -l 12/12.ext \
-operation "a+b+c+...+k+l"


Is there a straightforward way to do this?
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0