Solved

"tree" equivalent in a Unix AIX Environment

Posted on 2008-10-06
7
5,450 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

710 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