This repository has been archived on 2025-03-13. You can view files and clone it, but cannot push or open issues or pull requests.
Ion-Todo-Planner/txt_to_cmd.sh
2024-03-28 20:18:59 +01:00

25 lines
676 B
Bash
Executable file

#!/bin/bash
rm commands.sql -v
# File to read
file="dump.txt"
# Counter for line number
line_number=1
# Read each line of the file
while IFS= read -r line; do
# Store the line in a variable
variable_name="line_$line_number"
declare "$variable_name"="$line"
# Increment the line number counter
((line_number++))
done < "$file"
# Print the variables to verify
for ((i=1; i<line_number; i++)); do
var="line_$i"
date=$(date +%s)
echo "INSERT INTO \"main\".\"todo\"(\"ID\",\"TODO\",\"CREATION_DATE\",\"DUE_DATE\",\"PRIO\",\"IMP\") VALUES (NULL,'${!var}','$date','$(($date+60))',1,0);" >> commands.sql
done
echo converted $file to sql statements