Many additions and changes

This commit is contained in:
Matheus Albino Brunhara
2024-07-25 14:27:47 -03:00
parent 38bd245285
commit 9e8948bd92
9 changed files with 216 additions and 43 deletions

View File

@@ -0,0 +1,27 @@
#!/bin/bash
show_help() {
echo "Usage: $0 [--files|-f files]"
echo "Options:"
echo " --help | -h (Optional) Display help information on how to use this script"
echo " --key | -k (Required) Specify the key's name"
echo " --new-value | -v (Required) Specify the new value for the key"
echo " --file-path | -f (Required) Specify the file's path"
}
key=''
new_value=''
file_path=''
while [ "$#" -gt 0 ]; do
case "$1" in
--help|-h) show_help; exit ;;
--key|-k) key="$2"; shift 2;;
--new-value|-v) new_value="$2"; shift 2;;
--file-path|-f) file_path="$2"; shift 2;;
*) shift ;;
esac
done
old_value=`cat $file_path | grep $key | awk -F= '{print $2}'`
sed -i "s/$old_value/$new_value/g" $file_path