[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Copiar arquivos com espaço no nome
From: |
Cléoson Barreto |
Subject: |
Re: [shell-script] Copiar arquivos com espaço no nome |
Date: |
Thu, 23 Dec 2010 11:05:41 -0300 |
Olá!
Tenta o seguinte:
$ find /media/hd -print0 -iname \*jpg | xargs -0 -I{} cp '{}' /media/bkp/
O "segredo" de copiar os arquivos com espaço está na opção "-print0" do
find e opção "-0" do xargs.
Do man do find:
-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 programs that process the find output. This
option corresponds to the -0 option of xargs.
Do man do xargs:
-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.
--
[]'s
Cléoson.
http://farinhadigital.blogspot.com/
Em 23 de dezembro de 2010 10:13, Diego Neves <address@hidden>escreveu:
>
>
> Estou precisando fazer um backup de uma partição windows, tem varias fotos,
> em varias pastas, coloquei um live cd
> e peço pra copiar via terminal
>
> "cp `find /media/hd | grep jpg.` /media/bkp/"
>
> Porem os nomes de arquivo ou pasta que contem espaço da um erro. alguma
> sugestão?
>
> --
> *# Diego Neves #*
> Twitter <http://twitter.com/diegoaceneves> | MSN
> <address@hidden<diegonevesmg%40hotmail.com>
> >|
> Blog <http://blog.softecsystems.com.br/diego/> |
> Orkut<http://www.orkut.com.br/Main#Profile?uid=6683253064488139899&rl=t>
> -----------------------------------------
> # Cel (OI) 33 88147387 #
> # Cel (TIM) 33 91992567 #
>
> [As partes desta mensagem que não continham texto foram removidas]
>
[As partes desta mensagem que não continham texto foram removidas]