home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!spool.mu.edu!hri.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news.mit.edu!jdell
- From: jdell@zenobia.mit.edu (John Ellithorpe)
- Newsgroups: comp.unix.shell
- Subject: Help with awk
- Message-ID: <JDELL.92Sep14134304@zenobia.mit.edu>
- Date: 14 Sep 92 18:43:04 GMT
- Sender: news@athena.mit.edu (News system)
- Distribution: comp.unix.shell
- Organization: Massachusetts Institute of Technology
- Lines: 31
- Nntp-Posting-Host: zenobia.mit.edu
-
- Hi,
-
- I've got a question about awk. I need to minimum match with a variable in
- a shell script. What I want to do is something like:
-
- #!/bin/sh
- tstusr=$1
- user=`awk -F: '$1 ~ /^$tstusr/ {print $1}' passwd`
- echo $user
-
- And in the passwd file is:
-
- jdell:...
-
- So, when I run the script:
-
- % script jde
- jdell
-
- it should come up with the minimum matched username(s). But I can't get
- awk to recognize /^$tstusr/. Is there a way to do this?
-
- John
- --
-
- ===============================================================================
- John Ellithorpe | Internet: jdell@maggie.mit.edu
- Dept. of Physics, Rm 26-349 | Phone : (617) 253-3074 Office
- Massachusetts Institute of Technology | (617) 253-3072 Lab
- Cambridge, MA 02139 | (617) 236-4910 Home
- ===============================================================================
-