bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in find (?)


From: Stepan Kasal
Subject: Re: Bug in find (?)
Date: Mon, 5 Aug 2002 11:12:29 +0000 (UTC)
User-agent: slrn/0.9.6.2 (Linux)

Hallo,

On Mon, 5 Aug 2002 11:24:03 +0200, address@hidden wrote:
> I'am using the really comfortable find utility (find version 4.1 on
> AIX 4.3 or find version 4.17 on Win XP (cygwin)).
>
> I would like to produce a list of directories for a makefile:
>
> /home/gnu/bin/find . -name "*.c" -printf "%h \\\n"
> 
> But either the line continuation '\\' or the newline '\n' is not recognized.

[followup set, please find further discussion in comp.unix.shell]

        I'm afraid it's a mistake on your side.  I hope I'm right
that you'd like to generate lines looking like this:

./extension \

In C, printf interprets % directives only.  find's -printf, OTOH,
interprets % directives as well as \ escapes.  (See the man page.)

Within double quotes, shell usually interprets \ escapes.  This interferes
with the find's interpretation.  So you type "\\\n", the shell understands
"\\" as '\', and doesn't understand "\n" thus leaves it.  The find program
then sees \\n and prints backslash, followed by the letter n.
You'd have to put five or six backslashes in a row to achieve the desired
result (at least in my environment).

But it is more convenient, at least with Bourne type shells (eg. cygwin's
bash), to use single qoutes.  That way the shell won't try to interpret
the backslash escapes and find will see exactly what you type:

        find . -name "*.c" -printf '%h \\\n'
or
        find . -name '*.c' -printf '%h \\\n'

Hope this helps,
        Stepan Kasal





reply via email to

[Prev in Thread] Current Thread [Next in Thread]