我正在尝试使用从目录加载的文件名。
它运行正常,但一旦文件名有空格它就不起作用。
我将演示:
假设你在文件夹中scriptExample
有三个文件名dummy file one
, dummy file two
, dummy file three
。
cat
我的脚本对每个文件执行简单的命令
#!/bin/bash
for i in *
do
cat $i
done
然而当你运行这个时你会得到:
cat: dummy: No such file or directory
cat: file: No such file or directory
cat: one: No such file or directory
cat: dummy: No such file or directory
cat: file: No such file or directory
cat: three: No such file or directory
cat: dummy: No such file or directory
cat: file: No such file or directory
cat: two: No such file or directory
#!/bin/bash
for i in *
do
cat $i
done