Bash script to generate URI for Broswer Updated: 2017-08-05

March 2017 ยท 1 minute read

Here’s a simple script that lets you throw URI date directly to the browser to render.

We want something that looks like:


Note: Running stuff as command line arguements you have to escape '<' and '>'
(at least in Bash you do)
Another consideration is that browsers and commands do not like whitespace,
replace with '%20'

currentt=$(date) #linux date command
p='Body information!'

a="data:text/html,<h1>" #open header
b="</h1><p>" #close header open body
c="</p>" #close body

url=$a$h1$b$p$c #concatinate strings

url=${url// /%20} #replace all spaces with %20

firefox $url #open browser with link

A little tidbit from the URI standard that’s often overlooked!