Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
Hello, I want links to files in one directory to appear in another directory, when i do a directory listing for that dir.
For example, I want links of all subdirs and files of hdf/video/tv.shows to appear in video/tv.shows , when i do an ls of video/tv.shows, and to work when I use mplayer on it. I've not been able to achieve this with ln, especially not the second requirement, that the links should be usable too...
To link all files and directories at one level, I tried:
(Run in the target directory--ie where the links will be**)
ln -s /path1/path2/*
This does not work, and I am a little fuzzy as to why not. But, this works:
for item in `ls /path1/path2/`;do ln -s /path/path/$item; done
This links everything in /path1/path2 into the current folder. I suppose you could make it recursive by adding a bit more code.....first, you'd have to use SED or something to filter the extra junk you get when you do ls -R.
**I always find that "linking in" is most reliable and consistent---ie run the ln command in the directory where the links will be.
If you have nested directories and you want links to all the files in the hierarchy to be created in one directory you can do this from the directory you want the links created in:
Code:
find /hdf/video/tv.shows -name '*avi' | while read video; do ln -s $video; done
I've done that here and mplayer has no problem using the links.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.