Solved

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

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

 

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

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.

Question has a verified solution.

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

Suggested Solutions

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…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

732 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