[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

Is it possible to create a symbolic link to the output of a command?

I'd like to try to do something like this:

ln -s "tac ~/myfile.txt" linkname

the above of course doesn't work but is there some way to achieve this effect?

Essentially I want a symbolic link to a file with the contents in the reverse order.
0
opike
Asked:
opike
5 Solutions
 
sakmanCommented:
If I understand you correctly, then nope.  A symbolic link just points to an existing file an only contains the information needed to find that file.
0
 
TintinCommented:
Not possible.

A symbolic link can't reference a file that has different content.

0
 
wesly_chenCommented:
> ln -s "tac ~/myfile.txt" linkname
tac  ~/myfile.txt  >  linkname

If the content of ~/myfile.txt is changed constantly, then set up a cron job to run it frequently.

crontab -e
* * * * *  /usr/bin/tac  /home/<login name>/myfile  > /hone/<login name>/linkname
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
opikeAuthor Commented:
@wesley - That was my plan b.  I was hoping there was some way to point directly to the reverse of the file rather then set up some intermediate, periodic copy-type operation, but apparently there isn't.
0
 
wesly_chenCommented:
symbolic link is a pointer to a EXISTING file or directory.
The file with different content will be the different file. So you need to have that file exist before you can create symbolic point to it.
0
 
Hugh FraserConsultantCommented:
Depending upon how sophisticated you want to go or how important it is to accomplish something like this, you could look at FUSE (Filesystem in Userspace) at

http://fuse.sourceforge.net/

This allows you to have a file that effectively maps to some code you've created, which in your case could be a view of a file in reverse order.
0
 
ozoCommented:
Are you asking for something like
ln -s `tac ~/myfile.txt` linkname
or are you trying to do something more like
cat >linkname <<END
#!/bin/sh
tac ~/myfile.txt
END
chmod a+x linkname
0
 
opikeAuthor Commented:
I my ultimate goal was to access a file from a url through webserver (and I wanted a direct link, not something that would be periodically copied).

I knew this could be done through php (which is what I ended up doing) but I wanted to see if it could be done through a shell script (more out of curiosity I suppose).
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now