【发布时间】:2014-11-05 17:30:08
【问题描述】:
我和我的合作伙伴在使用这个基本的 Linux 脚本时遇到了问题。我们的讲师向我们倾倒了一个高级 Linux 脚本包进行调试,我们都非常迷茫。该脚本假设删除文件名中包含嵌入空格的文件,我被困在实际的 rm 命令上。我得到“缺少操作数”,我不知道该怎么办。
#!/bin/bash
# This script is supposed to delete all filenames in current directory
#+ containing embedded spaces.
# It doesn't work
# Why not?
badname= ls | grep " "
# Try this:
echo "$badname"
rm "$badname"
exit 0
【问题讨论】:
-
您收到什么错误或消息?