Solved

How do I show the full path for directories in Unix?

Posted on 2008-10-06
3
862 Views
Last Modified: 2013-12-26
I need to list the full paths to subdirectories within a given directory in Unix.  Here's what I'm using to find the directories:


cd /usr/test
find * -type d

This give me the following:
yrcw
yrcw/includes
yrcw/pdf

How can I modify the 'find' command to also show the full path such as the following:
/usr/testyrcw
/usr/testyrcw/includes
/usr/testyrcw/pdf

Thanks, and look forward to some help!

0
Comment
Question by:aggunia
3 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 63 total points
ID: 22651131
Hello aggunia,

find . -type d | while read name
do
   dirname=`echo $name | sed 's/^\.//'`
   echo `pwd`$dirname
done

Regards,

sunnycoder
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 62 total points
ID: 22651370
try

dir=/usr/test
cd $dir
find * -type d | while read d
do
   echo $dir/$d
done
0
 

Author Closing Comment

by:aggunia
ID: 31503462
Both of these solutions worked, so split up the points.  Thanks a lot!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sum67 challenge 35 93
post4 challenge 28 93
canBalance challenge 34 70
Execute multiple curl cmds with sleep and send output to file 10 88
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 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

20 Experts available now in Live!

Get 1:1 Help Now