0
我是linux的新手。當我嘗試這個時,我一直在學習貓命令。流水線的貓和ls命令
[email protected]:~$ cat file
Videos/Arrow/Season*
[email protected]:~$ cat file | ls -l
該命令將顯示當前文件夾的文件中提到的文件夾,而不是內容。但是,當我預期的文件夾中顯示的內容正確地做這個
[email protected]enovo-G50-45:~$ cat file
Videos/Arrow/Season*
[email protected]:~$ ls -l $(cat file)
。爲什麼不能在這種情況下使用管道?
您不能將文本「管道」到'ls'作爲文件名。 ls不接受這種方式。你必須使用xargs,例如'cat file | xargs ls -l'。 xargs從stdin獲取數據並將其作爲命令行參數傳遞給指定的命令('ls -l')。 –