![如何将行作为完整字符串输入命令](https://linux22.com/image/231276/%E5%A6%82%E4%BD%95%E5%B0%86%E8%A1%8C%E4%BD%9C%E4%B8%BA%E5%AE%8C%E6%95%B4%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%BE%93%E5%85%A5%E5%91%BD%E4%BB%A4.png)
包含带有空格的文件的目录
$ ls .
'File A' 'File B' 'File C'
$ walk .
.
./File A
./File B
./File C
ls 将每个空格解释为一个新文件
$ ls -ld $(walk .)
ls: cannot access './File': No such file or directory
ls: cannot access 'A': No such file or directory
ls: cannot access './File': No such file or directory
ls: cannot access 'B': No such file or directory
ls: cannot access './File': No such file or directory
ls: cannot access 'C': No such file or directory
drwxr-xr-x 1 nathan users 36 Apr 27 16:56 .
[ble: exit 2]
在行周围加上引号
$ walk . | sed 's/.*/"&"/'
"."
"./File A"
"./File B"
"./File C"
不起作用
$ ls -ld $(walk . | sed 's/.*/"&"/')
ls: cannot access '"."': No such file or directory
ls: cannot access '"./File': No such file or directory
ls: cannot access 'A"': No such file or directory
ls: cannot access '"./File': No such file or directory
ls: cannot access 'B"': No such file or directory
ls: cannot access '"./File': No such file or directory
ls: cannot access 'C"': No such file or directory
[ble: exit 2]