Solved

"tree" equivalent in a Unix AIX Environment

Posted on 2008-10-06
7
5,140 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

776 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