initial scripts

This commit is contained in:
Techognito 2025-08-14 22:15:11 +02:00
parent 6b14aa4acd
commit 77e9c9186a
5 changed files with 320 additions and 0 deletions

View file

@ -0,0 +1,45 @@
#!/bin/bash
# Input and output files
input_file="columnized.txt"
output_file="decolumnized.txt"
# Process the input file
awk '
# Function to print the table header
function print_table_header(table) {
if (table != "") {
print ""
print "### " table
table = ""
}
}
/^ *TABLE [0-9]+/ { # Detect table headers
table = $0
next
}
/^[0-9]+[0-9]+/ || /^[0-9]+/ { # Match rows starting with "16", "79", etc.
left = substr($0, 1, 50) # Extract left column (first 50 chars)
right = substr($0, 51) # Extract right column (remaining chars)
# Trim whitespace from both sides of each column
gsub(/ +$/, "", left)
gsub(/^ +/, "", left)
gsub(/ +$/, "", right)
gsub(/^ +/, "", right)
# Print the table header if a new row is starting
print_table_header(table)
# Print left column (if it exists) as part of the output
if (left != "") {
print "- **" left "**: " right
} else if (right != "") {
print right
}
}' "$input_file" > "$output_file"
echo "Reformatted content saved to $output_file"