[英]How to copy all files with the same name into another directory using cp command
我有名為“文檔”的目錄。 在此目錄中,我有5個文件:
User1.txt
User2.txt
User3.txt
User4.txt
User5.txt
Users-info.zip
index.html
我只想將名稱中帶有單詞“ user”的那些文件復制到另一個目錄。 如何使用cp命令執行此操作?
cp User* /path/to/dir
嘗試一下,就足夠了。
如果您希望使用不尋常的方式:
find . -type f -name 'User*' -print0 | xargs -0 cp -t /path/to/dir/for/copies/
對於您的情況是:
cp User[1-9].txt /dst_dir
我們只復制User
開頭的文件,而不是一些數字,最后是.txt
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.