我有一个名为“员工”的文件夹,并在该文件夹中有每个员工名称的子文件夹。
employee >> amar >> akbar >> anthony
每个文件夹都包含1或2个文件。 有大约50名员工。 我想复制所有这些文件到一个新的文件夹“/ home / employee_files”没有子文件夹。 换句话说,当我列出“ls / home / employee_files”时,所有文件都应该可用
$ cp employee/*/* /home/employee_files/
find /home/attachments/ -type f -exec cp {} /home/attachments_all/ \;
请注意,如果两个文件具有相同的名称,则只能以其中一个文件结束。
另一种方法是将文件复制到其内容的散列名称。
#!/bin/bash cp "$1" /home/attachments_all/`sha1sum "$1" | cut -f 1 -d ' '`
这将给你每个文件的独特副本,不pipe之前命名。 您可以改变脚本为您提供一个索引文件。
find /home/attachments/ -name "*.*" -exec scp {} /home/attachments_all/ \;