0

I'm having a problem with a script I'm writing.

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 is seeing the blocksize in the IF statements as a command rather than a variable. How can I fix this?

1 Answer 1

2

You shouldn't put spaces around = on assignments:

blocksize=0

instead of

blocksize = 0

should work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.