cancel
Showing results for 
Search instead for 
Did you mean: 

Absolute path

SOLVED
Go to solution
arunthoray
Occasional Advisor

Absolute path

 

How can i write absolute path of the entire  directory into a file in a folder?

 

 

4 REPLIES
Patrick Wallek
Honored Contributor

Re: Absolute path

# cd /abc/def/ghi

# echo ${PWD} >> afile

 

# cat file

/abc/def/ghi

arunthoray
Occasional Advisor

Re: Absolute path

My question is, how can i list all directories presnt in a directory to a file.Suppose five directories are inside on directory and i wnated to list entire directories absolute path in a file..

Patrick Wallek
Honored Contributor
Solution

Re: Absolute path

Do you just want the directories in your current directory or do you want to traverse the entire directory structure?

 

For example:

 

Do you want only these directories:

# ls -l |grep ^drw
drwxr-xr-x  20 root       sys           8192 May 23 07:10 .
drwxr-xr-x  26 root       root          8192 May 15 11:15 ..
drwxr-xr-x  11 root       sys           8192 Apr 19  2011 .dt
drwx------   2 root       sys             96 Jan 25  2010 .elm
drwx------   2 root       sys           8192 Feb 17  2011 .gnupg
drwx------   2 root       sys             96 Aug 16  2010 .hh
drwx------   3 root       sys             96 Jun 30  2011 .java
drwx------   3 root       sys             96 Sep 13  2011 .mozilla
drwx------   2 root       sys           8192 Aug 25  2010 .ssh
drwxr-xr-x   6 root       sys           8192 Jun  1  2011 .sw
drwx------   4 root       root            96 Oct  9  2010 .swa
drwxr-xr-x   2 root       sys           8192 Dec 21 16:09 Functions
drwx------   2 root       sys             96 Jun 16  2011 MWAtools
drwxr-xr-x   2 root       sys             96 Dec 10  2010 Mail
drwxr-xr-x   2 root       sys           8192 May 23 09:38 bin
drwxr-xr-x   2 root       sys           8192 Apr 23 13:08 cfg-scripts
drwx------   4 root       sys           8192 Jan  8 13:54 dev
drwxr-xr-x   2 root       sys             96 Nov 11  2009 old
drwx------   3 root       sys             96 Jun 30  2011 omniback
drwxr-xr-x   2 root       sys           8192 Feb 27  2011 zamboni

 Or do you want the entire directory tree.  For example, the following is the structure from the omniback directory:

 

# ll omniback/
total 16
drwx------   3 root       sys             96 Jun 30  2011 .
drwxr-xr-x  20 root       sys           8192 May 23 07:10 ..
drwx------   3 root       sys             96 Jun 30  2011 config
# ll omniback/config
total 0
drwx------   3 root       sys             96 Jun 30  2011 .
drwx------   3 root       sys             96 Jun 30  2011 ..
drwx------   3 root       sys             96 Jun 30  2011 client
# ll omniback/config/client
total 0
drwx------   3 root       sys             96 Jun 30  2011 .
drwx------   3 root       sys             96 Jun 30  2011 ..
drwx------   2 root       sys             96 Jan 24 16:28 javagui

 

If you want the ENTIRE directory structure for your current working directory you can do:

 

# find ${PWD} -type d > afile

Dennis Handly
Acclaimed Contributor

Re: Absolute path

># echo ${PWD} >> afile

 

If your path contains symlinks, you may want to use "pwd -P" to get the actual physical path.