LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 08-23-2007, 12:56 PM   #1
mirshafie
LQ Newbie
 
Registered: Aug 2007
Posts: 1

Rep: Reputation: 0
Linking a directory


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...

Is it possible?

Thanks for taking the time.
 
Old 08-23-2007, 08:46 PM   #2
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
what command syntax did you use? and what happened?

I'm coming from Solaris and can't reach a linux box right now to do a man. But I would try

cd video/tv.shows
ln -s ../../hdf/video/tv.shows/* .

If the "*" didn't work in this setting, then one at a time.

Of course, you gave relative paths, so I'm assuming the paths above are correct. You could avoid that assumption by using absolute paths.

Check `man ln` in your OS to see if that correct for you.
 
Old 08-23-2007, 09:18 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I don't see a recursion option in ln.

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.

Last edited by pixellany; 08-23-2007 at 09:20 PM.
 
Old 08-23-2007, 09:27 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
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.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Username & Password Sync Fedora Directory and Microsoft Active Directory karnac01 Fedora 4 07-19-2010 12:51 AM
Bash script: symbolic linking all files with same extension in a directory Katachi Programming 1 12-25-2006 09:42 AM
Linking a directory for ftp user riemann_noodles Slackware 3 11-14-2006 11:15 PM
Problem in using both load time linking and runtime linking durgaprasad_j Linux - General 0 08-01-2006 03:49 AM
linking directory problem lomaree Linux - General 3 01-05-2004 01:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:02 PM.

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