home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / shell / 3885 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.5 KB  |  56 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!ftpbox!mothost!schbbs!maccvm.corp.mot.com!W10075
  3. From: W10075@maccvm.corp.mot.com (Stephen Weet)
  4. Subject: Re: How to do $#a in Bourne shell?
  5. Organization: Motorola
  6. Date: 10 Sep 1992 08:45:04 CDT
  7. Message-ID: <1992Sep10.140321.19154@schbbs.mot.com>
  8. Sender: news@schbbs.mot.com (Net News)
  9. Nntp-Posting-Host: maccvm.corp.mot.com
  10. Lines: 44
  11.  
  12. ------------------------- Original Article -------------------------
  13. Newsgroups: comp.unix.shell
  14. Path:
  15. schbbs!mothost!ftpbox!uunet!europa.asd.contel.com!darwin.sura.net!convex!news.ut
  16. dallas.edu!corpgate!bnrgate!nrcnet0!cunews!torn!csd.unb.ca!morgan.ucs.mun.ca!nst
  17. n.ns.ca!dragon.acadiau.ca!merlin!peter
  18. From: peter@merlin.acadiau.ca (Peter Steele)
  19. Subject: How to do $#a in Bourne shell?
  20. Message-ID: <peter.716085132@merlin>
  21. Sender: news@dragon.acadiau.ca
  22. Nntp-Posting-Host: merlin
  23. Organization: Acadia University
  24. Date: Thu, 10 Sep 1992 00:32:12 GMT
  25. Lines: 8
  26.  
  27. If I have a list in Bourne shell, how can I determine how many
  28. elements are in, short of write a for loop and counting them?
  29. Bourne shell doesn't seem to have C shell's $#variable construct.
  30. It doesn't seem to support array indexing either, although I'm just
  31. learning it and I might be missing something....
  32. --
  33. Peter Steele        Unix Services Manager            peter.steele@acadiau.ca
  34. Acadia Univ., Wolfville, NS, Canada B0P 1X0  902-542-2201  Fax: 902-542-4364
  35.  
  36.  
  37.  
  38. Try the following :-
  39.  
  40.      LIST="1 2 3 4 5 6"
  41.      set $LIST          # set elements of list as pos params
  42.      echo $#            # No . of pos params
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.