← Back to team overview

sslug-teknik team mailing list archive

Re: Bash-mystik - eller er det xview der driller ?

 

On ons, 2005-11-30 at 12:02 -0800, Jan Holst Jensen wrote:
> > Ville `find . -maxdepth 1 -name \*.jpg -print0 |
> > xargs -0 xview` så
> > ikke være en anelse mere elegant og sikkert?
> 
> Det er jo fantastisk! Det virker :-) ! Men hvorfor ??
> Hvordan kan "find" finde ud af at sende korrekt
> quotede filnavne afsted ? Bruger den 
> 
>   01\ januar.jpg
> 
> istedet for
> 
>   "01 januar.jpg"
> 
> ? Og hvorfor virker den sidste så ikke som output fra
> et script men godt på kommandolinien ?

fra find(1):

-print0
    True; print the full file name on the standard output,  followed
    by  a  null  character  (instead  of  the newline character that
    `-print' uses).  This allows file names that contain newlines or
    other  types  of white space to be correctly interpreted by pro-
    grams that process the find output.  This option corresponds  to
    the `-0' option of xargs.

fra xargs(1):

--null, -0
    Input  items  are  terminated  by a null character instead of by
    whitespace, and the quotes and backslash are not special  (every
    character is taken literally).  Disables the end of file string,
    which is treated like any other  argument.   Useful  when  input
    items  might  contain  white space, quote marks, or backslashes.
    The GNU find -print0 option produces  input  suitable  for  this
    mode.

-- 
Christian Joergensen | void factorize_primes_in_linear_time () { 
http://www.razor.dk/ |   // todo: implement function
                     | }

Attachment: signature.asc
Description: This is a digitally signed message part


Follow ups

References