Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
(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).
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.
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.
(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
(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):
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.