SORU
7 EKİM 2009, ÇARŞAMBA


Linux: kopyala ve eğer varsa hedef dizin oluştur

Eğer varsa hedef dizin oluşturur bir komut istiyorum (ya da muhtemelen cp için bir seçenek).

Örnek:

cp -? file /path/to/copy/file/to/is/very/deep/there

CEVAP
4 Ocak 2012, ÇARŞAMBA


Her ikisi de şu gerçek var: eğer

  1. cp (ve, örneğin, Mac sürümü değil) GNU sürümünü kullanıyorsanız, ve
  2. Bazı mevcut dizin yapısını kopyalıyor ve size sadece bunu yeniden gerekir

cp --parents bayrağı ile bunu yapabilirsiniz. Bilgi Sayfası () info cp man cp http://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html#cp-invocation ya da görüntülenebilir:

--parents
     Form the name of each destination file by appending to the target
     directory a slash and the specified name of the source file.  The
     last argument given to `cp' must be the name of an existing
     directory.  For example, the command:

          cp --parents a/b/c existing_dir

     copies the file `a/b/c' to `existing_dir/a/b/c', creating any
     missing intermediate directories.

Örnek:

/tmp $ mkdir foo
/tmp $ mkdir foo/foo
/tmp $ touch foo/foo/foo.txt
/tmp $ mkdir bar
/tmp $ cp --parents foo/foo/foo.txt bar
/tmp $ ls bar/foo/foo
foo.txt

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Missouri Star Quilt Company

    Missouri Sta

    18 ŞUBAT 2009
  • MobileTechReview

    MobileTechRe

    6 HAZİRAN 2008
  • theatre2film

    theatre2film

    12 NİSAN 2006