delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/08/10/17:48:34

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
Message-ID: <42FA7608.4070501@serv.net>
Date: Wed, 10 Aug 2005 14:47:52 -0700
From: L Anderson <lowella AT serv DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8b) Gecko/20050217
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Programatically finding value of "cygdrive" prefix
References: <42FA4604 DOT 8000507 AT tlinx DOT org> <20050810183616 DOT GA5892 AT trixie DOT casa DOT cgf DOT cx> <20050810184119 DOT GA6155 AT trixie DOT casa DOT cgf DOT cx>
In-Reply-To: <20050810184119.GA6155@trixie.casa.cgf.cx>
X-IsSubscribed: yes

Christopher Faylor wrote:
> On Wed, Aug 10, 2005 at 02:36:16PM -0400, Christopher Faylor wrote:
> 
>>On Wed, Aug 10, 2005 at 11:23:00AM -0700, Linda W wrote:
>>
>>>Is there a way to find out in a bash script the cygdrive prefix?
>>>I thought something simple like
>>>  mount -p|tail -1|cut -f1
>>>but that incorrectly assumed the fields were tab delimited.
>>>Since there can be spaces in the cygdrive prefix, I can't
>>>use space a delimiter, example:
>>># mount -p
>>>Prefix              Type         Flags
>>>/cyg drive posix path  system       binmode
>>>----
>>
>>There may be a simpler way to do it, but this seems to work:
>>
>>mount -p | sed -n '2s/\([^ ]\)  *[^ ][^ ]*  *[^ ][^ ]*$/\1/p'
> 
> 
> This is shorter:
> 
> mount -p | sed -nr '2s/([^ ]) +\S+ +\S+$/\1/p'
> 

Neither of which work if there is a space in the cygdrive prefix; viz a viz:

  Prefix              Type         Flags
/cyg drive posix path  system       binmode

However,

mount -p | sed -nr '2s/([^ ].*) +\S+ +\S+/\1/p'

does the trick.


Regards,

L Anderson




--
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/

- Raw text -


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