Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recursive directory listing

Status
Not open for further replies.

orjazmik

MIS
Oct 2, 2002
9
US
I'm looking to create a "directory map" of our development AIX server to familiarize myself with the box, and see what I should be looking to for cleanup purposes. I'm having trouble figuring out the best way to approach this. If anyone out there has any ideas, any input would be greatly appreciated.
Thanks,

Marshall
 
If you want a recursive listing of *all* files, do ls -lR as root. Beware, it'll be big though!

Greg.
 
look also at 'man find' a great tool!!
to list only dirs in .
find . -type d
for long list
find . -type d | xargs ls -l vox clamantis in deserto.
 
Shell version that I use:
(watch out for symlinks in nested dirs, they will cause
you unholy problems.)

function ex_w_err() {
msg=${1:-"undefined"}
printf "$msg\n"
exit 1 > /dev/null
}

function recur() {
dir=$1
if [ ! -z "$dir" ] ; then
for xx in $dir/*
do
if [ -d "$xx" ] ; then
echo "Descending into $xx"
recur "$xx" || ex_w_err "Failed in recursion at $dir/$xx"
else
echo "$xx"
fi
done
else
ex_w_err "Target directory was not passed to function recur()."
fi
return $?
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top