Opening Multiple URLs at Once from CLI
I’ve been keeping text files of my daily discoveries since around 2006. That is
when I started using Linux for everyday tasks at home. And when I’m at work,
I’d just try to do as much through Cygwin. Anyway, I ended up having to look up
the same stuff repeatedly like how to burn a cd using dd
, or how to setup
sshd
in Cygwin. One day, I just created a folder called kb
and started
pasting the commands into various text files called vim.txt
,
sshd_on_cygwin.txt
, etc. At the bottom of each of those files, I would paste
the URLs where I found those commands. Ten years later, I find myself doing
this more often especially because I’m dealing with a lot more tools and
techonlogies than before. Everyday is filled with npm this
, gem that
,
patch here
, and drush there
. When I get quite time, though, I like to read
through the references from the most recent notes.
Here is how I would open the references with Chrome:
Show contents of file:
cat notes.txt
Output:
This is a text file.
## Resources
- http://example.com/source-1
- http://example.com/source-2
- http://example.com/source-3
- http://example.com/source-4
- http://example.com/source-5
- http://example.com/source-6
- http://example.com/source-7
For the last five lines, strip out leading dashes, strip out blank lines, and open each in Chrome:
cat notes.txt | tail -5 | sed 's/^- //' | grep -v -e '^$' | xargs -n 1 open -a 'Google Chrome'