Solved

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

Posted on 2011-09-26
8
372 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux Mint 18 31 89
ipconfig not working on windows 10 bash shell; what other commands are missing. 17 167
ftp to port 21 4 43
number in printf 13 27
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
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…
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 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.:

776 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