I'd like to make links to all files in a directory tree. Which means, create the same directory structure and make the links in them to the respective subdirectory in the original dir.  That could be done with   cp -R -s ../foo .   But - that needs an absolute path. So rather  cp -R -s `readlink -e ../foo` `readlink -e .`   I would like the resulting links to be relative.  Is there some easy way? E.g. some script or program specialized for that.
120793
I'd like to make links to all files in a directory tree. Which means, create the same directory structure and make the links in them to the respective subdirectory in the original dir.  That could be done with   cp -R -s ../foo .   But - that needs an absolute path. So rather  cp -R -s `readlink -e ../foo` `readlink -e .`   I would like the resulting links to be relative.  How would I do that?
42577
I'm trying to recursively search a directory tree to find all of the .asp files using the following command:  dir *.asp /s   For some reason, this returns not only the asp files, but also the aspx files.  How can I force it to ignore the aspx files?
38314
touch ~/deleted/$(echo "directory_"$(readlink -f foo)|tr '/' '\') 2&gt; /dev/null   where foo is a directory  It's reading the full pathname of foo and creating it as a file replacing all '/' with '\' and putting a directory_ in front so the directory  /home/test/foo would create a file directory_\home\test\foo  It does exactly what I want except a warning keeps printing tr: warning: an unescaped backslash at end of string is not portable   a. I don't know what that means b. I would like it to not show  I tried to redirect stderr to /dev/null but it doesn't work. How do I suppress it?
64318
How do I copy an entire directory into a directory of the same name without replacing the content in the destination directory? (instead, I would like to add to the contents of the destination folder)
93336
Let's say you have directories /dir1 and /dir2/linked, where the latter is a symlink to the former.   When you cd to linked and pwd, you get the output /dir2/linked. If you then cd .., you'll be put on /dir2. This behaviour is consistent with the concept of you being in /dir2/linked before. However, as I understand it, the parent directory (..) of any directory is stored in the directory inode (i.e.:physically in the disk). Obviously,  since /dir2/linked is really /dir1, the parent directory on the inode must be /  To further complicate matters, while inside /dir2/linked, the outputs of ls .. and cd .. ; ls . are different! It seems like cd honors the symlinked path, while ls honors the "physical" path. As mentioned in , there's cd -P for this use case, though.  man pwd mentions "physical" and "logical" working directories, but I still have a few questions at this point:   Is this behaviour always provided by the PWD environment variable, as mentioned in man pwd? Why do default cd and ls have different behaviours, if they're both shell commands (i.e.: not programs)? Does the typical program (not shell command) use PWD instead of the physical path? I realize it's up to the implementation, but is there any rule of thumb?
89650
This is merely just a vocabulary question, but which keeps turning around in my head.  It comes from a practice exam from a  preparation book. The correct answer according to the book is that ~/Documents is a relative directory because it is relative to the home directory.  However, this book contains an honourable ratio of typos and mistakes so I cannot take for granted everything which is written there. Here I do not agree because for me ~ acts as a variable expanded by the shell into either the content of the $HOME variable or the current user home directory path (cf. ), so the actual path is /home/myuser/Documents which is indeed an absolute directory.  Even , for once, seems of no help to me on this topic (even if it seems to confirm that the book is wrong on this one):     An absolute or full path points to the same location in a file system   regardless of the current working directory. To do that, it must   contain the root directory.      By contrast, a relative path starts from some given working directory,   avoiding the need to provide the full absolute path.   Here again, I do not agree: according to this definition, the path /opt/kde3/bin/../lib which does not depends of the current working directory should be an absolute one, however my current understanding of this matches the book's author making this path a relative one.  A quick web-search is just adding to my frustration, according to :     absolute path - A path relative to the root directory. Its first character must be the pathname separator.   So $HOME/Documents, or even just $HOME would not be considered absolute directories? Or does this definition implies variable expansion? What about the shell's ~ character? Is there any reliable definition of relative vs. absolute directory I can find somewhere and am I wrong all of the way?
12023
I'm currently in a symbolic link directory and I want to go up one level in the absolute path, but I cant as it will hit me back up to my home directory (~). I can do pwd -P to get the absolute path, but how do I pipe that result into the cd command? I always thought it was this: {}   Sample:  10:21:55 {master *} ~/ch$ pwd -P  /home/drupal/sites/all/themes/house  10:22:16 {master *} ~/ch$ pwd -P | cd {} bash: cd: {}: No such file or directory  10:22:20 {master *} ~/ch$
116987
I always get messed up when need to use cp or mv: "do I need -R option when working with dir?" In GNU coreutils cp does need -R and mv doesn't.   I just can not find any reason why cp needs -R option for copying dirs and mv doesn't. I think that cping dirs without -R (but behaving recursively like there's -R and like mv does) wouldn't cause any problems except breaking someone's habits on using the tool.  Do you know any explanation? May be it had a reason long time ago?    Additional question: why don't coreutils developers make cp copy dirs recursively by default?
7201
Is there a linux command that I'm overlooking that makes it possible to do something along the lines of: (pseudo)  $ mkdir -R foo/bar/zoo/andsoforth   Or is there no alternative but to make the directories one at a time?
82553
I have a directory tree which has a bunch of symbolic links to files under /home... however, I have moved /home to /mnt/home and need a way to "relink" all of the symlinks. Does such functionality exist or do I need to write a script to do so?   As an example, I have something like the following:  [root@trees ~]# ls -l /mnt/home/someone/something total 4264 lrwxrwxrwx 1 jnet www-data      55 2011-08-07 13:50 a -&gt; /home/someone/someotherthing/a lrwxrwxrwx 1 jnet www-data      55 2011-08-07 13:50 b -&gt; /home/someone/someotherthing/b lrwxrwxrwx 1 jnet www-data      55 2011-08-07 13:50 c -&gt; /home/someone/someotherthing/c lrwxrwxrwx 1 jnet www-data      55 2011-08-07 13:50 d -&gt; /home/someone/someotherthing/d lrwxrwxrwx 1 jnet www-data      55 2011-08-07 13:50 e -&gt; /home/someone/someotherthing/e  /mnt/home/someone/something/subdir: total 4264 lrwxrwxrwx 1 jnet www-data      55 2011-08-07 13:50 a -&gt; /home/someone/someotherthing/subdir/a lrwxrwxrwx 1 jnet www-data      55 2011-08-07 13:50 b -&gt; /home/someone/someotherthing/subdir/b lrwxrwxrwx 1 jnet www-data      55 2011-08-07 13:50 c -&gt; /home/someone/someotherthing/subdir/c lrwxrwxrwx 1 jnet www-data      55 2011-08-07 13:50 d -&gt; /home/someone/someotherthing/subdir/d lrwxrwxrwx 1 jnet www-data      55 2011-08-07 13:50 e -&gt; /home/someone/someotherthing/subdir/e   I want a command which will find all the symlinks and relink to the same places but underneath /mnt/home instead of /home  Does such a command exist?
101920
How can I convert a relative path to an absolute path in C on Unix? Is there a convenient system function for this?  On Windows there is a GetFullPathName function that does the job, but I didn't find something similar on Unix...
82398
Suppose I have a directory structure like this:   $ [~/practice] ls a/ b/ c/ d/   Now I want to create a directory tmp1 in all sub directories of practice and I do this:   $ [~/practice] mkdir */tmp1 mkdir: cannot create directory `*/tmp1': No such file or directory   Then I try the -p switch and I endup with a directory named * with a sub directory tmp1   $ [~/practice] mkdir -p */tmp1  $ [~/practice] ls */ a/ b/ c/ d/   I know the use of -p switch is to create multiple nonexistent directories. I just thought it might help.  How do I create tmp1 in all subdirectories at once?   If this can be done, how do I extend it to create \tmp1, \tmp2, \tmp3 in \a, \b and \c at once?  Edit: I missed mentioning that the directories don't have to be simple and in order, like a, b, c etc., and the directory to be created is not necessarily like tmp1, tmp2.    $ [~/practice] ls dog/ cat/ rat/   In them, I would like to have something like   $ [~/practice] ls * dog: red/ blue/  cat: red/ blue/  rat: red/ blue/
9727
When I cd a link, my current path is prefixed with the link's path, rather than the path of the directory the link links to.  E.g.  ~/dirlinks/maths$ ls -l logic lrwxrwxrwx 1 tim tim 71 Jul 27 10:24 logic -&gt; /windows-d/academic discipline/study objects/areas/formal systems/logic  ~/dirlinks/maths$ cd logic ~/dirlinks/maths/logic$ pwd /home/tim/dirlinks/maths/logic  ~/dirlinks/maths/logic$ cd .. ~/dirlinks/maths$   I would like to have my current path changed to the path of the linked dir, so that I can work with the parent dirs of the linked dir as well. Besides ls the link to find out the linked dir, and then cd into it, what are some simpler ways to accomplish that? For example, after cd into a link, how do you change your current path to the path of the linked dir?
97411
I want an easy way to create multiple directories in C++/Linux.   For example I want to save a file lola.file in the directory:   /tmp/a/b/c   but if the directories are not there I want them to be created automagically. A working example would be perfect.
117933
I've created some hard links on my Windows 7 file system using mklink. It was some time ago and I can't remember for sure where, or which files. When I use Explorer, all files look the same. When I use the command line and type "dir", they all look the same.  How do I find hard links? Or how do I determine whether a specific file IS a hard link?
16593
I want to cp a file to another directory but that directory doesn't exist yet.  So I would do:  mkdir /new_place cp the_file /new_place   Can I do this in one? I imagine something like cp the_file -m /new_place if "m" stood for "make dir's that don't exist"  Would this be a chance to use scp, rsync or another copying utility?
19119
mkdir -p will create a directory; it will also make parent directories as needed.  Does a similar command exist for files, that will create a file and parent directories as needed?