delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/27/13:50:07

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Mon, 27 Sep 2004 13:49:35 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Dave Korn <dk AT artimi DOT com>
cc: cygwin AT cygwin DOT com
Subject: RE: "which" command does not expand "~" in path
In-Reply-To: <NUTMEGkxOjmfCHJr1Wt0000010a@NUTMEG.CAM.ARTIMI.COM>
Message-ID: <Pine.GSO.4.61.0409271347370.13693@slinky.cs.nyu.edu>
References: <NUTMEGkxOjmfCHJr1Wt0000010a AT NUTMEG DOT CAM DOT ARTIMI DOT COM>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.39

---559023410-1804928587-1096307375=:13693
Content-Type: TEXT/PLAIN; charset=iso-8859-1
Content-Transfer-Encoding: 8BIT

On Mon, 27 Sep 2004, Dave Korn wrote:

> > -----Original Message-----
> > From: cygwin-owner On Behalf Of Hannu E K Nevalainen
> > Sent: 27 September 2004 18:24
>
> > you wrote:
> >
> > > On Mon, 27 Sep 2004, Sven Köhler wrote:
>
> > >> I just wondered how to write a "correct" shell-script that
> > runs with
> > >> /bin/sh, and it seems there is no way "shell-script"-way to figure
> > >> out a  user's homedir.
> > >
> > > You could try
> > >
> > > awk -F: "/^username:/"'{print $6}' < /etc/passwd
> > >
> > > (the pattern is in double quotes so that variable substitution can
> > > occur, e.g., you could change "username" to "$1" in a shell script).
> > > Igor --
> >
> > $ u="Hannu";sed -nre "s/^$u.*:(.*):.*$/\1/p" </etc/passwd

This works only because "/" is not a valid variable name. :-p

> > I bet there are some more other ways to do it... ;-P
>
> My first thought was
>
> grep "username" /etc/passwd | cut -d ':' -f 6

Correction for the archives:

grep "^username:" /etc/passwd | cut -d ':' -f 6

	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw

---559023410-1804928587-1096307375=:13693
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
---559023410-1804928587-1096307375=:13693--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019