Solved

"tree" equivalent in a Unix AIX Environment

Posted on 2008-10-06
7
4,927 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now