溫馨提示×

如何用copirdir篩選特定文件

小樊
51
2025-03-29 08:13:58
欄目: 編程語言

cp 命令用于復制文件和目錄,而不是篩選文件。如果你想要篩選特定文件并復制它們,你可以結合使用 findls 命令與 cp 命令。

以下是一些示例:

  1. 使用 find 命令篩選特定文件并復制:
find /path/to/source -type f -name "*.txt" -exec cp {} /path/to/destination \;

這個命令會在 /path/to/source 目錄中查找所有擴展名為 .txt 的文件,并將它們復制到 /path/to/destination 目錄。

  1. 使用 ls 命令篩選特定文件并復制:
ls /path/to/source/*.txt | while read file; do cp "$file" /path/to/destination; done

這個命令會列出 /path/to/source 目錄中所有擴展名為 .txt 的文件,并將它們逐個復制到 /path/to/destination 目錄。

請注意,這些命令中的路徑需要根據你的實際情況進行修改。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女