Bash无法识别变量赋值
我写的剧本有问题Bash无法识别变量赋值,bash,scripting,Bash,Scripting,我写的剧本有问题 clear echo "Welcome to the dd interface" echo "NOTE: When this program executes you will have to provide root access" echo " " lsblk echo " " read -p "Enter the location of the disk to be imaged: " input_location echo "Input Location Assign
clear
echo "Welcome to the dd interface"
echo "NOTE: When this program executes you will have to provide root access"
echo " "
lsblk
echo " "
read -p "Enter the location of the disk to be imaged: " input_location
echo "Input Location Assigned"
echo " "
read -p "Enter the output location: " output_location
echo "Output Location Assigned"
echo "
1 - 512K
2 - 1024K
3 - 2048K
4 - 4096K
"
blocksize = 0
read -p "Select the write block size to be used: " selection
echo "Block write size selected"
#problem is here
if [[ $selection == 1 ]]; then
blocksize = 512
elif [[ $selection == 2 ]]; then
blocksize = 1024
elif [[ $selection == 3 ]]; then
blocksize = 2048
elif [[ $selection == 4 ]]; then
blocksize = 4096
fi
echo "Options selected:
Input location: $input_location
Output location: $output_location
Block size: $blocksize
"
Bash将IF语句中的blocksize视为命令而不是变量。如何解决此问题?您不应该在作业上的
=
周围放置空格:
blocksize=0
而不是
blocksize = 0
应该有用