home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sunic!psinntp!psinntp!ncrlnk!usglnk!usdsd1!dkowalsk
- From: dkowalsk@usdsd1.DaytonOH.NCR.COM (Dennis Kowalski)
- Newsgroups: comp.unix.shell
- Subject: Re: How to do $#a in Bourne shell?
- Message-ID: <1604@usdsd1.DaytonOH.NCR.COM>
- Date: 14 Sep 92 19:40:43 GMT
- References: <peter.716085132@merlin>
- Reply-To: dkowalsk@usdsd1.DaytonOH.NCR.COM (Dennis Kowalski)
- Organization: NCR USG Data Services Division
- Lines: 31
-
- In article <peter.716085132@merlin> peter@merlin.acadiau.ca (Peter Steele)
- writes:
- >If I have a list in Bourne shell, how can I determine how many
- >elements are in, short of write a for loop and counting them?
- >Bourne shell doesn't seem to have C shell's $#variable construct.
- >It doesn't seem to support array indexing either, although I'm just
- >learning it and I might be missing something....
- >--
- >Peter Steele Unix Services Manager peter.steele@acadiau.ca
- >Acadia Univ., Wolfville, NS, Canada B0P 1X0 902-542-2201 Fax: 902-542-4364
-
-
- You did not say where your list was. If it is in a file with one list
- member per line such as :
-
- aaa
- bbb
- ccc
-
- try this
-
- CNT=`cat listfile | wc -l`
-
- The variable CNT will have the number of lines in "listfile"
-
-
- --
- Dennis Kowalski NCR Corporation PCD-3 (513) 445-1843
- Systems Architecture 1700 S. Patterson Blvd VOICEplus 622-1843
- USG Data Services Div Dayton, Ohio 45479
- Dennis.Kowalski@DaytonOH.NCR.COM
-