LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-06-2009, 03:56 AM   #1
debajit_kataki
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Rep: Reputation: 0
PWD and TREE dir structure dump restore


I have two questions.

(1) When i change to a soft linked directory, i actually land up in a new location, but PWD command still shows, not the exact folder location but the soft link source folder only. How to see the actula present working Directory.

(2) I have a server, where i need to to take Dir Tree structure dump, only, as data is not of much important, but also, in time of scarctity, i will have to to immediately create all those dir struvcture as per the Tree command output. How would i be able to do it fast, as i have some thousand of (sub)(sub)(dir).


Regards
DEBU
 
Old 03-06-2009, 04:59 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

1) Use '/bin/pwd' instead of 'pwd' to get the real pathname.

2) Have a look at the 'install' command, and 'mkdir -p'. install will copy a file, and create all the parent directories as needed, mkdir -p will do the same sort of thing, but with directories.

Dave
 
Old 03-06-2009, 05:11 AM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
You could also do something like
# find /path/to/tree -type d > dirlist
to get a list of the directories.
Then
# for dir in `cat dirlist`; do mkdir "$dir"; done
to recreate them.

Dave
 
Old 03-07-2009, 09:20 AM   #4
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Quote:
Originally Posted by debajit_kataki View Post
I have two questions.

(1) When i change to a soft linked directory, i actually land up in a new location, but PWD command still shows, not the exact folder location but the soft link source folder only. How to see the actula present working Directory.
$ pwd -P

will show the physical path.

Quote:
Originally Posted by debajit_kataki View Post

(2) I have a server, where i need to to take Dir Tree structure dump, only, as data is not of much important, but also, in time of scarctity, i will have to to immediately create all those dir struvcture as per the Tree command output. How would i be able to do it fast, as i have some thousand of (sub)(sub)(dir).
The find command ilikejam mentions is perfect, but I saw situations where the command line got too long as the whole content of the directory listing will make one long shell line. It might be necsessary to call mkdir in smaller chunks (and keep the directory listing relative, i.e. avoiding the leading / to be included):

$ cd new_target_directory
$ (cd old_source_directory; find . -mindepth 1 -type d) | xargs -n 50 mkdir


-- Reuti
 
Old 03-11-2009, 09:01 AM   #5
debajit_kataki
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks Dave and Reuti. The solution really helped me.

~Best Regrads
Debu
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
restore file or dir from dump file brumela Linux - Newbie 7 01-19-2023 08:20 AM
removeing the files but tree structure should be same dina3e Linux - Newbie 1 03-23-2008 05:57 AM
PWD question : Current dir not full path facets Programming 2 06-09-2004 04:58 AM
Apache: making a dir with username and pwd fledermaus Linux - Networking 1 05-13-2004 09:40 AM
Recommendation for webpage tree structure Alan Powell Linux - Newbie 1 04-06-2004 02:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration