-e - Option turns environmental variable into a user variable or error if not defined.
-r - Read named variable.
-l - List all the available user variables.
+-g - List grep case insensitive by name available user variables.
-o - Output only the value of named variable, pipes out piped in.
-d - Delete the named uvar.
-s - Alternative store location (not recommended option to use).
[[ "$print" -eq "1" ]] && echo "$2"
exit;
}
-function list(){
+function list_grep(){
+#echo -e "$1=$2 - $argc"
for file in $STORE/.uvar_*
do
-#echo $file
n=$(echo $file | sed "s/$EXP//")
if [[ -f $file ]]; then
v=$(awk '{if (NR<6) print}END{if(NR > 5) \
print "\t---> THE DISPLAY HAS BEEN CUT AT LINE 5 FOR [" ARGV[1] "] <---\n\n"}' \
$file)
- echo -e "$n=$v"
+ if [[ -z "$1" ]]; then
+ echo -e "$n=$v"
+ else
+ echo -e "$n=$v" | grep -i "$1"
+ fi
fi
done
}
argv=("$@")
print=0
-while getopts ":e:d:r:n:v:s:f:p:lo" opt
+while getopts ":e:d:g:r:n:v:s:f:p:lo" opt
do
case "${opt}" in
s) if [[ -d "${OPTARG}" ]]; then
n) name=${OPTARG};;
v) value=${OPTARG};;
r) readUVAR ${OPTARG};;
- l) list;;
+ g) list_grep ${OPTARG}
+ exit;;
+ l) list_grep;;
f) [[ -f $STORE/.uvar_$name ]] && $(rm -f $STORE/.uvar_$name);
while read line; do
echo -e "$line" >> $STORE/.uvar_$name
name=$1; shift; value="$@"
writeUVAR $name "$value"
fi
-exit;
\ No newline at end of file
+exit;