This is my Bash script that reads values from a temperature sensor and shows them in a line. I want to separate my array elements by a comma, like this example: [1,2,3,5], then to replace a line that exists in another file by this string.
temp.sh:
#!/bin/bash
for ((i=0 ; 12 - $i ; i++))
do
x=$(cat /sys/bus/w1/devices/28-0000075292ed/w1_slave | grep "t=" | awk -F "t=" '{print $2/1000}')
field[$i]=$x
echo "${field[$i]}"
done | column
columndoing anything here? Does theechooutput more than one value on a given line? What does the output of this command look like exactly? What about if you don't usecolumn?fieldas a string? You can always domystr="${field[@]}"for a space separated string of values. If you want to remove the spaces, thentr -d ' ' <<<$mystr.