I use this script: #!/bin/bash inputtemp=$1 unit=${inputtemp: -1}…
- User
I use this script: #!/bin/bash
input_temp={input_temp: -1} value=${input_temp:0:-1}
if [ (echo "Kvalueresult elif [ (echo "Cvalueresult fi
- Assistant
The issue with your script is that you are trying to append the unit (
new_unit) directly after calculating the value. However,bcdoes not handle string concatenation, so the unit is not being appended to your result, hence, the output is just the unit itself (e.g., 'K' or 'C') without the numerical value.You need to modify the way you append the unit to your calculated value. Specifically, you should ensure that both the numerical value and the unit are correctly concatenated into the final result.
Here is the corrected script:
#!/bin/bash input_temp=$1 unit=${input_temp: -1} value=${input_temp:0:-1} if [ $unit == "C" ]; then Kvalue=$(echo "$value + 273" | bc) result="${Kvalue}K" echo $result elif [ $unit == "K" ]; then Cvalue=$(echo "$value - 273" | bc) result="${Cvalue}C" echo $result fiExplanation
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.