Solved

"tree" equivalent in a Unix AIX Environment

Posted on 2008-10-06
7
5,238 Views
Last Modified: 2013-11-17
I am doing a SAP migration from an onsite data farm to a Collocation out in Phoenix, IBM is requesting a hierarchy break down. instead of typing this all out i know in Linux there is a command such as tree. i have tried that on my AIX SAP machine and have gotten no response. is there an equivalent command on UNIX to get this structure read out, without the filenames in the directory also? Below is what im looking for. any help would be greatly appreciated.
.
   |-bin
   |-boot
   |---grub
   |---lost+found
   |-dev
   |---bus
   |-----usb
   |-------001
   |---disk
   |-----by-id
   |-----by-label
   |-----by-path
   |-----by-uuid
   |---input
   |---mapper
   |---net
   |---pts
   |---shm
   |-etc

0
Comment
Question by:techsupportcpm
  • 3
  • 2
7 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 22651227
Hello techsupportcpm,

You can try
find / -type d

replace / with whatever directory whose structure you wish to have. This would give you the directory structure but it would not be formatted like tree command - just one directory per line.

Regards,
sunnycoder
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 22651609
please see link below to create a tree script of your own:

http://www.centerkey.com/tree/
0
 
LVL 2

Author Comment

by:techsupportcpm
ID: 22651748
yea google already kicked back that search and it was tried. the command itself does not run "ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'" from a CLI.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 40

Accepted Solution

by:
omarfarid earned 250 total points
ID: 22651794
do you mean that the script does not run? have you downloaded the script or you just copy and paste from the site? I personally downloaded the script and ran it on solaris 10 and it is fine.

If you have problem then see the attached snippet

Google is of much help any way :)
#!/bin/sh
 
#######################################################
#  UNIX TREE                                          #
#  Version: 2.2                                       #
#  By Dem Pilafian                                    #
#  File: ~/apps/tree/tree.sh                          #
#                                                     #
#  Displays Structure of Directory Hierarchy          #
#  -------------------------------------------------  #
#  This tiny script uses "ls", "grep", and "sed"      #
#  in a single command to show the nesting of         #
#  sub-directories.                                   #
#                                                     #
#  Setup:                                             #
#     % cd ~/apps/tree                                #
#     % chmod u+x tree.sh                             #
#     % ln -s ~/apps/tree/tree.sh ~/bin/tree          #
#                                                     #
#  Usage:                                             #
#     % tree [directory]                              #
#                                                     #
#  Examples:                                          #
#     % tree                                          #
#     % tree /etc/opt                                 #
#     % tree ..                                       #
#                                                     #
#  Public Domain Software -- Free to Use as You Like  #
#  http://www.centerkey.com/tree                      #
#######################################################
 
echo
if [ "$1" != "" ]  #if parameter exists, use as base folder
   then cd "$1"
   fi
pwd
ls -R | grep ":$" |   \
   sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
# 1st sed: remove colons
# 2nd sed: replace higher level folder names with dashes
# 3rd sed: indent graph three spaces
# 4th sed: replace first dash with a vertical bar
if [ `ls -F -1 | grep "/" | wc -l` = 0 ]   # check if no folders
   then echo "   -> no sub-directories"
   fi
echo
exit

Open in new window

0
 
LVL 40

Expert Comment

by:omarfarid
ID: 22660354
techsupportcpm did not answer my last question although answer was provided
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 22665842
Why has the close process been restarted when omarfarid has posted a valid objection?
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question