Я думаю, что необходимо измениться valid users = ashley joe %S
к только valid users = %S
. В Вашем примере, ashley, joe and %S [the name of the share]
всегда допустимо, таким образом, ashley
и joe
может достигнуть всех домов, любой другой (если существует), пользователи должны только видеть свое собственное в примере, который Вы дали.
Ваш пример как есть не будет работать, потому что копия не копирует структуры каталогов, она только скопирует файлы, следовательно сообщение об ошибке, с которым Вы встречаетесь. Чтобы сделать глубокую копию, такую как это, можно включить в список любого tar
управляйте и используйте конструкцию tar cvf - --files-from=... | (cd /home/tmp/test/files/; tar xvf -)
или можно просто использовать rsync
.
На вашем месте я использовал бы rsync
сделать это как так:
$ rsync -avz --files-from=abc.txt /src /home/tmp/test/files/.
Если Вы только хотите 1-е 100 строк из файла abc.txt
можно сделать это:
$ rsync -avz --files-from=<(head -n 100 abc.txt) /src /home/tmp/test/files/.
Демонстрационные данные папки:
$ tree /home/saml/tmp/folder*
/home/saml/tmp/folder1
`-- example.tar.gz
/home/saml/tmp/folder2
`-- example.tar.gz
/home/saml/tmp/folder3
`-- example.tar.gz
Теперь скопируйте файлы:
$ rsync -avz --files-from=<(head -n 3 /home/saml/tmp/abc.txt) \
/home/saml/tmp/. /home/saml/tmp/test/files/.
building file list ... done
./
folder1/
folder1/example.tar.gz
folder2/
folder2/example.tar.gz
folder3/
folder3/example.tar.gz
sent 3147093 bytes received 81 bytes 6294348.00 bytes/sec
total size is 3145728 speedup is 1.00
Подтвердите, что они были скопированы:
$ tree /home/saml/tmp/test/files
/home/saml/tmp/test/files
|-- folder1
| `-- example.tar.gz
|-- folder2
| `-- example.tar.gz
`-- folder3
`-- example.tar.gz
Если Вы заинтересовали, вот то, как Вы делаете это использующий просто tar
.
$ cd /home/saml/tmp
$ tar cvf - --files-from=<(head -n 3 /home/saml/tmp/abc.txt) | (cd /home/saml/tmp/test/files/; tar xvf -)
./folder1/example.tar.gz
./folder1/example.tar.gz
./folder2/example.tar.gz
./folder2/example.tar.gz
./folder3/example.tar.gz
./folder3/example.tar.gz
Подтвердите, что это скопировало:
$ tree /home/saml/tmp/test/files
/home/saml/tmp/test/files
|-- folder1
| `-- example.tar.gz
|-- folder2
| `-- example.tar.gz
`-- folder3
`-- example.tar.gz
El problema ciertamente no es que cp
no copie estructuras de directorios. Por supuesto que lo hace:cp -r
(recursivo ).
Lo que cp
, al menos POSIX cp
, no hace es volver a -crear las rutas relativas de los operandos de origen en el directorio de destino.
Si cp a/b/file1 a/b/file2 a/c/file3 dest
entonces obtienes dest/file1 dest/file2 dest/file3
.
Si su cp
es el de GNU Coreutils, puede tener la opción --parents
. No estoy seguro de cuándo se introdujo. cp --parents
inducirá a GNU cp
a producir este mecanismo de creación de ruta -. De la documentación de Info:
--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.
Entonces, si tiene GNU cp
, el único cambio que necesita es eliminar el -r
ya que no estamos recurriendo, y usar--parents
:
cp --parents -f `head -n 100 /home/tmp/abc.txt` /home/tmp/test/files
head -n 100 /home/tmp/abc.txt
/home/tmp/test/./home/tmp/test/files Это также копирует только один example.tar.gz в целевой folder.what, является неправильным в этом или как использовать файлы - от в этой команде? – Mano 17.08.2013, 09:18head
управляйте, как введено к--files-from=
список. Я добавлю его к ответу. – slm♦ 17.08.2013, 09:24