- 论坛徽章:
- 2
|
nvram(){
local file=~/SoftwareFactory/shellExercises/enb/enb.nvram;
case "$1" in
show)
awk '{printf("%s=",$1);system("echo " $2 "|base64 -d|gzip -cd");}' "$file";
;;
get)
awk -v s2="$2" '$1==s2{system("echo " $2 "|base64 -d|gzip -cd");}' "$file";
;;
set)
item="${2%%=*}";
value=$(echo "${2#*=}"|gzip -c|base64|tr -d '\n');
awk -v item="$item" -v value="$value" -v file="$file" '$1!=item{printf("%s\n",$0)>file;} END{printf("%s%s%s\n",item,FS,value)>file;}' "$file";
;;
unset)
item="${2%%=*}";
awk -v item="$item" -v file="$file" '$1!=item{print $0>file;}' "$file";
;;
*)
echo "Parameter error";
esac
}
|
|