Search code examples
linuxubuntuchromiumgnome-terminal

how to open all shortcuts files from a directory with chromium-browser in one command


On ubuntu 16.04, i have a directory with these files :

-rw-rw-r-- 1 user0 user0  86 jui  7 21:32 vim html picker.url
-rw-rw-r-- 1 user0 user0 104 jui  7 21:32 cocoonjs build android apk.url
-rw-rw-r-- 1 user0 user0  61 jui  7 21:32 Simple Modal Window - Codepad.url
-rw-rw-r-- 1 user0 user0  96 jui  7 21:32 cocoon.js android build apk+++.url
-rw-rw-r-- 1 user0 user0  44 jui  7 21:32 CodePen - Front End Developer Playground & Code Editor in the Browser (1).url

The file "vim html picker.url" have this information :

-->  cat vim\ html\ picker.url 

[InternetShortcut]
URL=https://github.com/KabbAmine/vCoolor.vim/blob/master/README.md

what i want to do is open all of theses files from this directory in tab in my chromium-browser.

i have tried this in my gnome-terminal :

chromium-browser *.*  

but chrome open the text information : URL=https://github.com/KabbAmine/vCoolor.vim/blob/master/README.md and not the url itself :https://github.com/KabbAmine/vCoolor.vim/blob/master/README.md.

wich command allow my desired behaviour ?


Solution

  • grep "^URL=" *.url | cut -d= -f2 | xargs chromium-browser should do the trick.

    Explanation:

    • grep "^URL=" *.url - cut the line beginning with URL= from each file ending in .url
    • cut -d= -f2 - split each remaining line into parts delimited by '=' and output the second and all subsequent parts (i.e. the part after the first '=')
    • xargs chromium-browser - use the list of URLs as arguments to chromium.