The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Transfer files wih directory structure. uxlunatick SCO 11 04-28-2008 03:25 PM
Recursion to Copy a Directory structure avrkiran Shell Programming and Scripting 2 03-31-2008 02:43 AM
Copying with directory structure Cnfsed UNIX for Dummies Questions & Answers 4 11-29-2007 12:51 AM
MV files from one directory structure(multiple level) to other directory structure srmadab UNIX for Advanced & Expert Users 4 09-13-2006 04:01 PM
Copying a Directory Structure to a new structure jhansrod UNIX for Dummies Questions & Answers 8 07-27-2005 06:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-29-2007
murtaza murtaza is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 31
Need help in Directory Structure

I have writen the following code to show the dirctory structure. Can any body help me for using the recursive function in this code?

echo "-(0)"
echo "$HOME-(1)"

cd ~
set *

for i in `ls $HOME`
do
if [ -d "${i}" ]
then
echo ".....${i}"
cd $HOME/${i}
set *

for j in `ls $HOME/${i}`
do
if [ -d "${j}" ]
then
echo "..........${j}"
cd $HOME/${i}/${j}
set *

for k in `ls $HOME/${i}/${j}`
do
if [ -d "${k}" ]
then
echo "................${k}"
else
echo -n ""
fi
done
else
echo -n ""
fi
done
else
echo -n ""
fi

cd ~
set *
done

Thanks in advance.
  #2 (permalink)  
Old 03-29-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
Please use code tags.
It would be much simpler if you started with something like this:
Code:
find . -type d
which produces a directory tree, then you can format the output.
  #3 (permalink)  
Old 03-29-2007
murtaza murtaza is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 31
Thank u very much for giving me a nice simple solution. But can you give me the hint for the outputf format. e.g
$HOME
.........aaa
...............aaa1
................aaa2
........................aaa21
Thanks for interest and help.
  #4 (permalink)  
Old 03-29-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Care to search the forum ? Try printing directories
  #5 (permalink)  
Old 03-29-2007
murtaza murtaza is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 31
Thanks for interest but i do not want to use the sed, awk and perl commands.

Thanks,
  #6 (permalink)  
Old 03-29-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Your interest in 'not using sed,awk and perl' makes me wonder if you are attempting your homework questions in the forum.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0