delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/08/06/15:35:04

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: <42F510D7.1030600@byu.net>
Date: Sat, 06 Aug 2005 13:34:47 -0600
From: Eric Blake <ebb9 AT byu DOT net>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
MIME-Version: 1.0
To: Peter Farley <pjfarley3 AT yahoo DOT com>
CC: list Cygwin <cygwin AT cygwin DOT com>
Subject: Re: Question about coreutils common option "-"
References: <20050806191127 DOT 35121 DOT qmail AT web30208 DOT mail DOT mud DOT yahoo DOT com>
In-Reply-To: <20050806191127.35121.qmail@web30208.mail.mud.yahoo.com>
X-IsSubscribed: yes

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Peter Farley on 8/6/2005 1:11 PM:
> I thought the following would produce "ls -l" output
> for the space-separated list of files selected by the
> "find" options, but instead I get an error message
> from "ls":
> 
> $ find a -daystart -type f -mtime 7 -printf " %p"|ls
> -l -
> ls: -: No such file or directory

ls doesn't read stdin.  Instead, use xargs, which does read a list of
filenames on stdin and turns it into arguments, or else use find itself to
pass the filename on to ls:

find a -daystart -type f -mtime 7 -printf " %p" | xargs ls -l
find a -daystart -type f -mtime 7 | xargs ls -l
find a -daystart -type f -mtime 7 -exec ls -l {} \;

By the way, the first two have problems with spaces in filenames, and also
if there are no filenames found, so if you really want to use xargs, try:

find a -daystart -type f -mtype 7 -print0 | xargs -r0 ls -l

Or if you like ls -dils instead of ls -l:

find a -daystart -type f -mtime 7 -ls

> I do not have an *ix system on which to test if this
> is a Cygwin coreutils problem or a misunderstanding by
> me of the operation of the "-" option.  Can you please
> tell me if I am wrong about my use of the "-" option?

This is not a cygwin-specific problem, but a general misunderstanding on
your part how find and ls work.  Read up on their man or info pages.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9 AT byu DOT net
volunteer cygwin coreutils maintainer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFC9RDW84KuGfSFAYARAkm+AKDX/7HmbYTkYFgFnsDXMBHriIttfwCfbMC9
ySS5GrAHjxfJCN6HbOBxkSY=
=1u/b
-----END PGP SIGNATURE-----

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