whileループ内でユーザー入力を受け入れる方法

whileループ内でユーザー入力を受け入れる方法

私はシェルスクリプトに初めてアクセスし、ユーザーが正しく入力したことを確認するまで入力を続けるように求めるループを作成しようとしています。これを行うためにwhileループを使用しようとするとエラーが発生します。

joyentmac2252:scripts jessebutryn$ ./bashprofilemod.sh
Please enter your Joyent Public Cloud (JPC) username and press [ENTER]: 
jesse.butryn
The username you entered is: jesse.butryn Is this correct? y/n :n
./bashprofilemod.sh: line 13: syntax error near unexpected token `fi'
./bashprofilemod.sh: line 13: `  fi'

これまでの完全なスクリプトは以下にあります。本当に汚れたらすみませんが、まだ理解しています。次のステップに進む前にwhileループを操作しようとしているため、まだ完了していません。

#!/bin/sh
#Prompts user for their Joyent Cloud username (usually first.last)
read -p "Please enter your Joyent Public Cloud (JPC) username and press [ENTER]: " username
#Confirms user input
read -p "The username you entered is: $username Is this correct? y/n :" uconf
#
while [ $uconf = "N" -o $uconf = "n" ]
do
  read -p "Please enter your Joyent Public Cloud (JPC) username and press [ENTER]: " username
  read -p "The username you entered is: $username Is this correct? y/n :" uconf
  if [ $uconf = "Y" -o $uconf = "y" ]
    echo "Thanks your username will be entered as: $username$."
  fi
done

どんなアドバイスもありがとう

ベストアンサー1

thenこれら2つのドアを使用しませんでしたif

if [ $uconf = "Y" -o $uconf = "y" ];then
    echo "Thanks your username will be entered as: ${txtcyn}$username${txtrst}."
 fi



 if [ $kconf = "Y" -o $kconf = "y" ];then 
     echo "Thanks your ssh public key will be entered as: ${txtcyn}$HOME/.ssh/$sshkey${txtrst}."
 fi

おすすめ記事