delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/08/12:43:42

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: Wed, 8 Jun 2005 12:43:24 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Andrew DeFaria <Andrew AT DeFaria DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: launch windows program from shell according to its extension
In-Reply-To: <d873ef$o3u$1@sea.gmane.org>
Message-ID: <Pine.GSO.4.61.0506081219300.4945@slinky.cs.nyu.edu>
References: <sq0ea11hv6jnomcj848i6pjhchlrcupadc AT 4ax DOT com> <Pine DOT GSO DOT 4 DOT 61 DOT 0506081055090 DOT 4945 AT slinky DOT cs DOT nyu DOT edu> <ki2ea11bf1n5985j6ksn9g25vi9v3m10dp AT 4ax DOT com> <d873ef$o3u$1 AT sea DOT gmane DOT org>
MIME-Version: 1.0

On Wed, 8 Jun 2005, Andrew DeFaria wrote:

> zzapper wrote:
>
> > On Wed, 8 Jun 2005 10:59:27 -0400 (EDT), wrote:
> >
> > > > #!/bin/bash
> > > > # csn
> > > > # description : launch most recent file (head)
> > > > # set -x
> > > > cygstart $(l\s -t * | head -1) &
> > >
> > > Make that 'cygstart "$(/bin/ls -t | head -1)"' (add quotes, otherwise
> > > filenames with spaces will not work).
> >
> > Slightly improved to ignore directories (and assuming that Windows files
> > always have an extension) cygstart "$(/bin/ls -t *.* | head -1)"
>
> You're making an invalid assumption that directories do not have extensions.
> They can!
>
> The following works:
>
> cygstart $(ll -t | grep -v "^d" | head -2 | tail -1 | awk '{print $NF}')

Only if you have "alias ll='/bin/ls -l'" (and it has a big problem with
spaces in filenames, of course).  You can do the following instead:

cygstart "$(/bin/ls -FLt | sed -n '\,[/=|]$,!{s/\*$//;p;q}')"

This will launch the newest file if found, or Windows Explorer in the
current directory.  Not launching Explorer is actually harder than just
letting it be.
	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!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

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