1
#!/bin/bash
while read user;
do
echo "Do you want to send the message to $user?"
read response
case $response in
Y|y) echo The message was sent;;
N|n) echo The message was not sent;;
Q|q) exit;;
esac
done < users
なぜこのコードはUbuntuで動作しませんか?次のコードを実行すると、それが実行されます。なぜ "読み取り"コマンドが機能しないのですか?
#!/bin/bash
while read user;
do
echo "Do you want to send the message to $user?"
done < users
慣用的なやり方は、ファイル「users」を読み込むために別のファイル記述子を使用することです。 –
'IFS =" "read -r'は、空白を保存するのに理想的です。 – Inian
ありがとう@Inian、あなたはいつも私の間違いを訂正します。ありがとう。 –