How can I run something more simpler than:
echo date
> tmp.html && firefox tmp.html && rm tmp.html
Is it possible to get the same without creating and deleting the tmp.html?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this community/tmp
is cleared on boot, so you can do this
date > /tmp/date.html && firefox /tmp/date.html
if you want to open the result of any command in a browser, add this to your shell startup script
function open_in_browser {
echo $@ > /tmp/temp.html
firefox /tmp/temp.html
}
and then you can call
$ open_in_browser `date`
alternatively, if you'd prefer a more secure approach with stdin and better styling, you can use this function instead
function stdin_to_browser {
local tmpfile=`mktemp /tmp/command-output.XXXXX.html`
cat - > ${tmpfile}
sed -i -e '1{s#^#<pre>#;};${s#$#</pre>#;}' ${tmpfile}
firefox ${tmpfile} 2> /dev/null
}
which would let you
ifconfig | stdin_to_browser
(this example uses @thrig's suggestion of mktemp
)
firefox a.html
...