Opening several websites with awk

I was in a mess, I had to do a manual task. Everytime, I need to do a manual task, I think a way to automate it. Some months ago, I had a text file which contains several URLs. I had to open these URLs in Google Chrome.

So, the simple and most foolish (or Intelligent, I don’t know :) ) was to open the text file, copy each URLs one by one and paste them in the address bar of the browser. However, I did started this but then I figured that, hey this is damn boring and in my life, surely there’ll will be many times I’ll have to do this, so Why not find a solution right now??

As usual, Linux is the arena for such things. So, I opened terminal and started with the following.

cat genesis_child.txt

This displayed all the URLs. So, now, I had to ensure that each URLs comes in this format

google-chrome URL

so, acheive this, I used awk. awk uses variables such as $n $1 $2 … to retrieve part of the line being displayed. So, now with awk, I managed to make it echo in the above format I described with the following code

cat genesis_child.txt | awk '{}{ print "google-chrome " $n }{}'

Now, that the code to display each URL was being displayed properly, I just had to make each line execute.

cat genesis_child.txt | awk '{}{ print "google-chrome " $n }{}' | /bin/bash

Try it, download the URLs file here and use the walk-through to achieve it only because its fun :)