#!/bin/sh value="$1" mypath=$( dirname $0 ) getvalpath="$mypath/getvalpath" . "$mypath/common" if [ ! "$value" ]; then echo "Usage: $0 VALUE" >&2 exit 3 fi valfile=$( $getvalpath $value ) valpath=$( dirname "$valfile" ) # attempt to create the dir if it doesn't exist mkdir -p "$valpath" 2>/dev/null if [ ! -r "$valfile" ]; then echo "Value not found or inaccessible" >&2 exit 4 fi cat "$valfile"