Skip Navigation

(Solved) Ways to run the join command on memory/variable contents instead of files?

Edit: I figured it out: The solution is over a process substitution operator: join <(echo "$var1") <(echo "$var2") See also the comment by @notabot@piefed.social below, this StackOverflow comment, and the GNU documentation.. ——— It's comparatively straightforward to use the content of one variable in join by using - to tell it to use standard input for that file: echo $variable | join - anotherfile However, is there a way to serve both input 'files' from variables, avoiding temporary files on the disk? It seems like the easiest way would be via creating and mounting a temporary partition via tmpfs, mount -t tmpfs -o size=50m tmpfs /mountpoint, and just create temporary files in there. And afterwards clean things up. So far I've also attempted here-documents, but apparently this too can only provide standard input, so that the other input still has to be served from a file. Maybe one can also try doing it via named pipes (mkfifo), but I fear this could introduce lots of potentialities for errors.

Comments