Directory_Source/file1,file2,file3,file4
Directory_Target/Combined.txt
我試過了:ls Directory_Source/{file1,file3} > Directory_Target/Combined.txt
但是txt里面的結果是 Directory_Source/file1......
然后嘗試了ls -d */{file1,file3} > Directory_Target/Combined.txt,同樣的結果。
是否可以在不更改命令的情況下實作我的目標?我必須做出什么改變。
uj5u.com熱心網友回復:
可能的解決方案:
ls Directory_Source/{file1,file3} | sed 's#.*/##' > Directory_Target/Combined.txt
要么
basename -a Directory_Source/{file1,file3} > Directory_Target/Combined.txt
有關更多解決方案,另請參閱https://superuser.com/q/209937/992527。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/432239.html
上一篇:如何獲取祖父母目錄的名稱?
