Results 1 to 10 of 12

Thread: How to call each argument in a while loop

Threaded View

  1. #1
    Join Date
    Feb 2013
    Beans
    27

    How to call each argument in a while loop

    I want to access each argument so I tried doing ${$counter2}} because that was my first intuition but I keep getting bad substitution error. Does anyone know how to do this?

    Code:
    typeset -i counter=1typeset -i counter2=1
    while [ $counter2 -le $# ] 
    do
    cat ${$counter2} | while read line 
    do
    echo "$counter. $line"
    counter=counter+1
    done
    counter2=counter2+1
    done
    Last edited by toad3000; March 10th, 2013 at 06:13 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •