Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Attempting to end up with something similar to this:

$ ls -l  
lrwxrwxrwx  1 user group   4 Jun 28  2010 foo -> /home/bar  
lrwxrwxrwx  1 user group   4 Jun 29  2010 foo -> /etc/bar  

The intention is to be able to move a file to foo & have it go to both destination directories for now. The goal is to eventually unlink /home/bar link after confirming there are no issues with moving the files to /etc/bar. I am restricted in that I am unable to change or add to the process that moves the files.

share|improve this question
2  
A little more detail about this 'process' which copies the files, and we might be able to dig up another solution for you. –  Bobby Jun 4 '10 at 14:04
    
The process is a vendor supplied perl script, which, because of company policy restrictions, can not be modified by anyone here. –  kds1398 Jun 4 '10 at 14:23

4 Answers 4

up vote 6 down vote accepted

No, a link may resolve to one and only one file/folder. More specifically, a folder may not contain more than one item with the same name, and the working directly would need to have two files named "foo" to do as you describe.

share|improve this answer
    
Two links to a single file named foo would have been more what I was looking for... I just used an arbitrary ls -l to try to show my desired result since I wasn't sure if a link could resolve to multiple files/folders. Anyway, I'm accepting your answer based on the properties of links you are describing, which is what I was unsure of. –  kds1398 Jun 4 '10 at 14:28
    
@kds1398: You can have multiple links to a single file: foo -> baz and bar -> baz. –  Dennis Williamson Jun 4 '10 at 15:20
    
@Dennis Williamson: My comment above was incorrect as I was looking for foo -> baz & foo -> bar in a single directory. –  kds1398 Jun 5 '10 at 17:48

A link can only point to one file, so you cannot have foo reference both /home/bar and /etc/bar. Depending on the nature of what you are trying to do, you may be able to accomplish your goal by having foo -> /etc/bar and then also set /home/bar -> /etc/bar.

share|improve this answer

You can use a named pipe and a continuously running process that uses tee to make the output go to multiple files.

$ mkfifo foo
$ while :; do tee -a /home/bar /etc/bar < foo > /dev/null 2>&1; done &
$ echo hello > foo
$ cat /home/bar
hello
$ cat /etc/bar
hello
share|improve this answer

Your best bet would probably be some kind of special moint on foo. I doubt that you can do this with just the mechanisms provided by the kernel (a union doesn't quite cover it ...), but it should be relatively easy to cook something up with fuse.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.