Hello.
I want to to backup some "default:" values from a file do some other job and after restore that "default:" values back.
The problem is that the source and destination file has a lot of default: strings in it but with different values...
So..
Here is an example:
A part of my source file named "config.json".
{ SPane:{
title:"Blinking effect",
description:"Control the way the LED blinks."
}},
{ SCheckBox:{
description:"Completely disable led notifications.",
label:"Disable LED",
default:0,
action:"generic /sys/class/sec/led/led_completely_disable"
}},
{ SCheckBox:{
description:"If disabled, the controller bypasses slope generation.",
label:"Enable LED fading",
default:1,
action:"generic /sys/class/sec/led/led_fade"
}},
{ SSeekBar:{
title:"Fade-in time period",
description:"Sets the time period of the rising slope.",
min:0, max:12, unit:"ms", step:1,
default:2,
action:"generic /sys/class/sec/led/led_fade_in_time"
}},
{ SSeekBar:{
title:"Fade-out time period",
description:"Sets the time period of the falling slope.",
min:0, max:20, unit:"ms", step:1,
default:8,
action:"generic /sys/class/sec/led/led_fade_out_time"
}},
With the code:
echo "$(cat config.json | grep default: | awk -F default '{print $2 }' | awk -F , '{print $1 }')" > def;
This it will output all default values to "def" file.
Like:
:0
:1
:2
:8
Note that some values also have strings in it...
So after some other commands the source file change those default values and simply i want to restore those values from "def" file to "config.json" file.
Wish to explain it ok.
Thanks