简体   繁体   English

bash脚本无法打开文本编辑器

[英]bash scripting not opening text editor

following code executed in a terminal opens a text editor and displays loop.txt: 在终端中执行的以下代码将打开文本编辑器并显示loop.txt:

if [ -f loopy.txt ]; then
rm loopy.txt
touch loopy.txt
for i in $( seq 1 10)
do
echo $i line added >> loopy.txt
done
xdg-open loopy.txt

if I run it as a script, text editor does not open. 如果我将其作为脚本运行,则文本编辑器不会打开。 Can anyone tell me why not? 谁能告诉我为什么?

Tks, Robert Tks,罗伯特

Your script cannot run as it is. 您的脚本无法按原样运行。 You forgot the "fi" following the "if" clause. 您忘记了“ if”子句后面的“ fi”。

if [ -f loopy.txt ]; then
   rm loopy.txt
   touch loopy.txt
fi # <----- you forgot that
for i in $( seq 1 10)
do
   echo $i line added >> loopy.txt
done
xdg-open loopy.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM