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
Passing args to URL to retrieve a file ToniS Shell Programming and Scripting 1 07-17-2008 11:35 AM
command line args 2 skooly5 UNIX for Dummies Questions & Answers 2 04-06-2008 09:36 PM
command line args skooly5 UNIX for Dummies Questions & Answers 2 04-06-2008 07:46 PM
Command line args enuenu High Level Programming 2 05-29-2007 12:19 AM
required command line args yoi2hot4ya UNIX for Dummies Questions & Answers 6 06-02-2005 06:50 PM

Closed Thread
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
  #1 (permalink)  
Old 05-25-2009
little_wonder little_wonder is offline
Registered User
  
 

Join Date: May 2009
Posts: 26
How to retrieve command line args one by on.

Hi,

I have to store all the command line arguments into an array.

I have the following code.

**********************
Code:
#! /bin/sh

set -A arr_no_updates

i=1
while [ i -le $# ]
do
        arr_no_updates[i]=$($i)
        echo ${arr_no_updates[$i]}
        i=$(($i+1))
done
****************


But i could not assign the argumen values. please help me!!

In addition, I wish to learn Functions writing in shell script. pls advice me some documrnts or websites. I am very much new to shell scripts. Pls help me to learn. Thank you all in advance..

-----Post Update-----

I have found the below way....
please convey me ,if any other better way of doing this. Thanks..

**************************

Code:
set -A arr_no_updates

echo $@

i=1

for arr in $@
do
        echo $arr
        i=$(($i+1))
done
***************************

Last edited by vidyadhar85; 05-25-2009 at 11:23 PM.. Reason: code tags added
  #2 (permalink)  
Old 05-26-2009
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
Code:
#!/bin/ksh
set -A arr $@
Closed Thread

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 11:27 AM.


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