|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Tree directory structure of Unix to get final node path
Hi,
I want to list all the last directories from mentioned base path. for eg: If i have a base path say /base/base1/ How can i get the path till last node in tree like directory structure of unix by applying any command. so that i will get following output. /base/base1/base2/final1/final2/last /base/base1/base2/final1/final3/last /base/base1/base2/final1/last /base/base1/base2/final1/final4/last |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
find /base/base1 -type d -name "last" -print |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
In short i want all the possible unique longest paths under base dir
|
|
#4
|
|||
|
|||
|
Its not necessary the last node is always "last"
|
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Did you try it out at least? Or do I misunderstand ![]() Code:
root@isau02:/data/tmp/testfeld> find bla -type d -print bla bla/yoyo bla/yoyo/last bla/yoyo/last/some root@isau02:/data/tmp/testfeld> find bla -type d -name last -print bla/yoyo/last root@isau02:/data/tmp/testfeld> |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
In the above directory structure mentioned by you I want only "bla/yoyo/last/some" to be printed.
i.e The longest unique path. Here the last node is "some". I hope it clears now. |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
A directory with no subdirectories contains only two directories "." and "..". Code:
#!/bin/ksh
find /base/base1/ -type d -print|sort|while read DIR
do
DIR_COUNT=`ls -la "${DIR}"|grep \^d|wc -l`
if [ ${DIR_COUNT} -eq 2 ]
then
echo "${DIR}"
fi
done |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| tree structure of the data | ThobiasVakayil | Shell Programming and Scripting | 2 | 03-27-2008 01:15 AM |
| Not able to copy the tree node text in HP UX, while easily done in window | friendanoop | HP-UX | 2 | 02-08-2007 06:52 PM |
| Not able to copy the tree node text in solaris, while easily done in window | friendanoop | Solaris | 3 | 02-01-2007 08:37 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 |
| Unix/Linux Directory Structure | gdboling | UNIX for Dummies Questions & Answers | 2 | 10-25-2001 11:00 AM |
|
|