Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这让我发疯,我将这个脚本粘贴在 shell 中:
a=""; for f in $(ls -d -- */); do if [[ "$a" != "index/" ]]; then a="$a---$f--- "; fi done; echo "$a";
我得到了什么?
---index/---
“index/”怎么可能不等于“index/”呢?
削减?句法?请帮忙...
a永远不会设置为"index/". f可能被设置为索引,因此,a被设置为其中包含---的内容。
a
"index/"
f
---
很难看出您要做什么,但您可能需要考虑检查f语句if而不是a.
if
if [[ "$a" != "index/" ]];
你需要:
if [[ "$f" != "index/" ]];