#!/bin/bash ID=$1 if [ $# -ne 1 ] then echo "usage $0 " exit 1 fi # Path to your SQLite database file DB_FILE="/mnt/params.db" #for ID in ` echo "select id from bands"|sqlite3 $DB_FILE" ` #do # Read the current value from the table current_value=$(sqlite3 "$DB_FILE" "SELECT name, start_freq, stop_freq FROM bands WHERE id = $ID") if [[ -z "$current_value" ]]; then echo "Record not found." exit 1 fi # Extract the current name and start_freq current_name=$(echo "$current_value" | cut -d '|' -f 1) current_start_freq=$(echo "$current_value" | cut -d '|' -f 2) current_stop_freq=$(echo "$current_value" | cut -d '|' -f 3) echo "Current value: Name: $current_name, Start-Freq: $current_start_freq, Stop-Freq: $current_stop_freq" # Prompt the user for a new name and start_freq read -p "Enter a new name: " new_name read -p "Enter a new start_freq: " new_start_freq read -p "Enter a new stop_freq: " new_stop_freq # Update the record sqlite3 "$DB_FILE" "UPDATE bands SET name = '$new_name', start_freq = $new_start_freq, stop_freq = $new_stop_freq WHERE id = $ID" # Verify the update updated_value=$(sqlite3 "$DB_FILE" "SELECT name, start_freq FROM bands WHERE id = $ID") updated_name=$(echo "$updated_value" | cut -d '|' -f 1) updated_start_freq=$(echo "$updated_value" | cut -d '|' -f 2) updated_stop=$(echo "$updated_value" | cut -d '|' -f 3) echo "Updated value: Name: $updated_name, Start-Freq: $updated_start_freq, Stop-Freq $updated_stop_freq" #done