bug-findutils
[Top][All Lists]
Advanced

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

examples in find's man page


From: Isabella Parakiss
Subject: examples in find's man page
Date: Tue, 26 Apr 2016 10:47:15 +0200
User-agent: Mutt/1.6.0 (2016-04-01)

find's man page has some god-awful examples:

> find . -type f -exec file '{}' \;
>
> Runs `file' on every file in or below the current directory.  Notice
> that the braces are enclosed in single quote marks to protect them
> from interpretation as shell script punctuation.  The semicolon is
> similarly protected by the use of a backslash, though single quotes
> could have been used in that case also.

{} needs to be quoted

> find repo/ -exec test -d {}/.svn \; -or \
> -exec test -d {}/.git \; -or -exec test -d {}/CVS \; \
> -print -prune

but {}/.svn doesn't



> find /sbin /usr/sbin -executable \! -readable -print

let's escape ! here for no reason

> find . -perm -444 -perm /222 ! -perm /111
> find . -perm -a+r -perm /a+w ! -perm /a+x

but not here because logic



> find . -name .snapshot -prune -o \( \! -name *~ -print0 \)|
> cpio -pmd0 /dest-dir

surely *~ doesn't need to be quoted

> NON-BUGS
>        $ find . -name *.c -print
>        find: paths must precede expression
>        Usage: find [-H] [-L] [-P] [-Olevel] [-D
>        help|tree|search|stat|rates|opt|exec] [path...] [expression]
>
>        This happens because *.c has been expanded by the shell
>        resulting in find actually receiving a command line like this:
>
>        find . -name bigram.c code.c frcode.c locate.c -print
>
>        That command is of course not going to work.  Instead of doing
>        things this way, you should enclose the pattern in quotes or
>        escape the wildcard:
>        $ find . -name '*.c' -print
>        $ find . -name \*.c -print

oh wait apparently wildcards should be quoted or escaped



please fix these, they're embarassing.

-- 
xoxo iza



reply via email to

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