Print directory name along with their path


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print directory name along with their path
# 1  
Old 07-14-2010
Print directory name along with their path

Can any one tell me that how can i print all directory with their path in a given parent directory.

i.e. parent directory /home/usr/

Now this shoe directory may contain sevral directory
/home/usr
dir1/
dir1.1/
dir1.2/
dir2
dir2.1/
dir2.2/
dir2.2.1/
dir2.2.1.1/
and so on.

Now output should be each directory name along with path i.e
/home/usr/dir1/
/home/usr/dir1/dir1.1/
/home/usr/dir1/dir1.2/
/home/usr/dir2/dir2.1/
/home/usr/dir2/dir2.2/dir2.2.1/
/home/usr/dir2/dir2.2/dir2.2.1/dir2.2.1.1/

Any kind of help will be appricated.

Please let me know if i am not clear
# 2  
Old 07-14-2010
Code:
find /home/usr -type d -print

# 3  
Old 07-14-2010
Try:

Code:
find /home/usr/ -type d

# 4  
Old 07-14-2010
Code:
cd /
find /home/usr -type d -print

# 5  
Old 07-18-2010
find `pwd` /home/user/ -type d
# 6  
Old 07-19-2010
thanks to all
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

What is the difference ../directory path and ./directory path in ksh?

What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies

2. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

3. UNIX for Advanced & Expert Users

A way to print only part of directory path

Hi, So I struggled to find a solution to the following problem: I want to make sed print only part of multiple different paths. So lets say we have /path/path1/path2/logs/bla/blabla /path/path1/path2/path3/logs/yadda/yadda/yadda Can someone suggest a way to make sed or other... (5 Replies)
Discussion started by: dampio
5 Replies

4. UNIX for Dummies Questions & Answers

Extract directory name from the full directory path in UNIX using shell scripting

My input is as below : /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt /splunk/scrubbed/triumph/ifind.triumph.txt From the above input I want to extract the file names only . Basically I want to... (5 Replies)
Discussion started by: IshuGupta
5 Replies

5. Shell Programming and Scripting

How to print only the final path of subdirectories?

Hello, stumped with the find command to show the final path of subdirectories. Used the command find /dir1 -type d Output: /dir1/dirA /dir1/dirA/dirB /dir1/dirA/dirB/dirC Desired output is: /dir1/dirA/dirB/dirC Please help with awk statement or find syntax. Thanks in... (6 Replies)
Discussion started by: ux4me
6 Replies

6. Shell Programming and Scripting

print all filenames in directory with path to another file

hi, i have a directory at /path/unix with the following files 1.txt 2.txt 3.txt 4.txt I want to make another file called filenames.txt at a different location called /path/home. So, my output file would be /path/home/filenames.txt with contents /path/unix/1.txt... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

7. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

8. Shell Programming and Scripting

Retrieve directory path from full file path through sh

Hi, I have a file abcd.txt which has contents in the form of full path file names i.e. $home> vi abcd.txt /a/b/c/r1.txt /q/w/e/r2.txt /z/x/c/r3.txt Now I want to retrieve only the directory path name for each row i.e /a/b/c/ /q/w/e/ How to get the same through shell script?... (7 Replies)
Discussion started by: royzlife
7 Replies

9. Shell Programming and Scripting

Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction? for FILE in `cat list`; do if ; then ... (1 Reply)
Discussion started by: overkill
1 Replies

10. Shell Programming and Scripting

split and print $PATH

Hello simple question : how can i split the $PATH by the ":" seperator with one liner ? mybe using awk is there any builtin function in awk that splits and prints the output ? thanks (2 Replies)
Discussion started by: umen
2 Replies
Login or Register to Ask a Question