This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about coreutils common option "-"


-----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@byu.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]