Skip to content

Instantly share code, notes, and snippets.

View Nikolai2038's full-sized avatar
❤️
Shell scripts and Anime girls

Nikolai Ivanov Nikolai2038

❤️
Shell scripts and Anime girls
View GitHub Profile
@Nikolai2038
Nikolai2038 / ini_file_variable_get.sh
Last active March 2, 2025 21:58
Bash: Get and set specified variable in specified section of `.ini` file using `awk`
#!/bin/bash
main() {
local ini_file="${1}" && { shift || true; }
local section_name="${1}" && { shift || true; }
local variable_name="${1}" && { shift || true; }
if [ -z "${ini_file}" ] || [ -z "${section_name}" ] || [ -z "${variable_name}" ]; then
echo "Usage: ini_file_variable_get.sh <ini_file> <section_name> <variable_name> [is_error_if_section_is_not_found=1] [is_error_if_variable_is_not_found=1]" >&2
return 1
fi