Solved

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

Posted on 2011-09-26
8
375 Views
Last Modified: 2012-05-12
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
Comment
Question by:opike
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 4

Accepted Solution

by:
sakman earned 126 total points
ID: 36601397
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
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 125 total points
ID: 36601688
Not possible.

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

0
 
LVL 38

Assisted Solution

by:wesly_chen
wesly_chen earned 125 total points
ID: 36602451
> 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
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 

Author Comment

by:opike
ID: 36634550
@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
 
LVL 38

Expert Comment

by:wesly_chen
ID: 36650960
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
 
LVL 12

Assisted Solution

by:hfraser
hfraser earned 62 total points
ID: 36699191
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
 
LVL 84

Assisted Solution

by:ozo
ozo earned 62 total points
ID: 36707782
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
 

Author Comment

by:opike
ID: 36714122
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question