#!bin/bash
echo Where?
read Where
echo What?
read What
echo Number?
read Number
for inc in ’seq 1 1 $Number’ do
if [ $Where = Screen ] then
echo $What
fi
if [ $Where = File ] then
echo $What > test1,txt
fi
done
当我运行它时,输入 Screen,然后输入 Marko,然后输入数字 5 它向我显示此错误 它向我显示意外标记附近的语法错误 if 'if [ $Where = Screen ] then'
答案1
你的for
陈述缺少一个分号。你要:
for inc in $( seq 1 1 "$Number" ); do
答案2
首先运行您的代码https://www.shellcheck.net/