如何将行作为完整字符串输入命令

如何将行作为完整字符串输入命令

包含带有空格的文件的目录

$ 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]

相关内容