我想將目標檔案作為命令的輸入。
我的目錄目前有混合目標檔案和權重檔案。(簡化)
(base) directory % ls
file_015_apple.txt
file_015_orange.txt
file_016_apple.txt
file_016_orange.txt
file_017_apple.txt
file_017_apple.weight.txt
file_017_orange.txt
file_017_orange.weight.txt
...
我只想回傳目標檔案,但不使用 grep。
因為它對命令不可讀。
ls -l file* | grep -v "weight"
我嘗試了很多事情都失敗了。
1044 ls file*.txt ! -name "*weight*"
1045 ls file*.txt ! -name *weight*
1046 ls file*.txt ^*weight*
1049 ls file*(^weight).txt
1055 ls file*.txt/^*weight.txt
如果我放置所有檔案,則會發生錯誤。
% command file_*.txt
*Error*: field_017_apple.weight.weight.txt not found
任何解決方案?
uj5u.com熱心網友回復:
請嘗試以下操作:
ls *~*weight.txt
您可能需要啟用擴展的 glob 選項:
setopt extendedglob
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/379248.html
