# /bin/bash #----------------------------------------------------------------------- # Description: list all parents of a given path. #----------------------------------------------------------------------- MYFULLPATH=$1 # Path must be supplied. if [ -z "${MYFULLPATH}" ]; then echo "Please supply a full path." exit 1 fi # Path must exist. # TODO - what if perms are broken on way to dest? #if [ ! -e "${MYFULLPATH}" ]; then # echo "${MYFULLPATH} not found." # exit 2 #fi # Path must contain a slash. # FIXME: need this here. NEWDIR=${MYFULLPATH} #----------------------------------------------------------------------- # Until the path is root, strip off the last part (the basename) # and append it to a list for listing later. By building the list # before the ls rather than listing as we go, the columns in the # ls output will be aligned. while [ ! "${NEWDIR}" == '/' -a ! "${NEWDIR}" == '.' ]; do DIRLIST="${DIRLIST} ${NEWDIR}" # Strip the last piece off of the given path. NEWDIR=`dirname ${NEWDIR}` #echo ${NEWDIR} #sleep 1 done echo ${DIRLIST} | xargs ls -lad #-----------------------------------------------------------------------