Solved

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

Posted on 2011-09-26
8
371 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
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
 

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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Migrating an SQL 2008 database to Oracle 12c 3 88
Codiing Non-Existent Links 4 65
AD LDAP LDS 3 47
Printing to old printer through Linux (CUPS) Print Server? 7 46
If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

930 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now