Awk in Yad file replace existing value

167 views Asked by At

My current bash script is:

#!/bin/bash

# Variables
fileloc="/home/jerry/scripts/widget"

# Backup file first
cp $fileloc $fileloc.backup

widedit=`(yad --title="Linux Lite - Widget Editor" --borders=20 --text="All fileds <span font='Roboto Bold 12'>MUST</span> have a value:\n" --form \
--field="Gap X (0 - total monitor width span in pixels): ":NUM '!0..100000!1' \
--field="Gap Y (0 - total monitor height span in pixels): ":NUM '!0..100000!1' \
--field="Transparent (yes or no ):":CB yes!no! \
--button=gtk-apply:0)`

# Write to configuration file

echo $widedit | awk '{ sub(/gap_x/,"gap_x "$1); print }' >> $fileloc
echo $widedit | awk '{ sub(/gap_x/,"gap_x "$2); print }' >> $fileloc
echo $widedit | awk '{ sub(/gap_x/,"gap_x "$3); print }' >> $fileloc

exit 0

I'm wanting to have the line in /home/jerry/scripts/widget that shows gap_x 65 to read the value I input into the yad box, then overwrite the existing value in the widget file. At this point I am stuck. Thank you in advance.

0

There are 0 answers