home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!clsi!mitch
- From: mitch@clsi (Mitchell N. Perilstein)
- Subject: Re: searching for 1st occurrence
- In-Reply-To: bduncan@ve3ied.UUCP's message of Fri, 14 Aug 1992 01:21:56 GMT
- Message-ID: <MITCH.92Aug16153742@mira.clsi>
- Sender: usenet@clsi.COM
- Organization: CAD Language Systems, Inc.
- References: <15m8aqINN6ci@seven-up.East.Sun.COM> <1992Aug14.012156.5499@ve3ied.UUCP>
- Date: 16 Aug 92 15:37:42
- Lines: 23
-
- > In article <15m8aqINN6ci@seven-up.East.Sun.COM> ltaylor@blinky.East.Sun.COM (Laura Taylor) writes:
- >Inside a shellscript, I would like to search for only the
- >first occurrence of a particular string, or in otherwords,
- >just one occurrence of the same string so I can set it to
- >a variable.
- >
- >For example, say in file called systems, there is a list of
- >all the system architectures something like...
- >
- >SS2
- >SS1
- >SS2
- >4/75
-
- You can just skip the grep and do it in one step:
-
- awk '/SS2/ {print; exit}' < systems
-
- You might want a better regexp, like /^SS2$/.
- ---
- Mitchell N. Perilstein 5457 Twin Knolls Rd
- CAD Language Systems, Inc. Suite 101
- 410-992-5700 Columbia, MD 21045-3259
-