You can open a PDF as a Bash variable (expressed as a path to the file) like this.
Set your variable:
Open the file like this:
open "$pdf" -a Preview
However, your example indicates that the file doesn't exist on your filesystem. If you want to open a raw data stream stored in a variable, I recommend echoing your variable, and piping it to
open using the
-f option like this.
Define your variable:
pdf=$(wget -qO- https://www.exploit-db.com/docs/english/44592-linux-restricted-shell-bypass-guide.pdf)
Open the raw data as a stream from standard input:
echo $pdf | open -f -a Preview
If you store the output of
wget -qO- … as a variable, as opposed to downloading the file onto your filesystem,
open won't know what to do as you're passing it the raw file data rather than the path to the file. In
man open ‘file’ refers to an openable file for the given application, the variable in your example is not that. The
-f option is useful in this scenario as your method of setting the variable involves storing the entire file stream, which won't be interpreted as a file by
open, and therefore it can only be opened as a file stream.