I am on CentOS 6.6. I have a program that runs analysis and outputs its data in html files.

The file structure is


I want to open all three html files from a bash one liner, e.g.

for i in dir*; do firefox --new-tab $i/${i}.html; done

This opens the files individually, such that the first html file must be closed before the second one opens. If I try to send it as a background process, e.g.

 for i in dir*; do firefox --new-tab $i/${i}.html&; done

I get:

-bash: syntax error near unexpected token `;'

I also tried the same method as in this post, but it still opens them individually.

How can I open these all in the same tab using a little bash one-liner?

marked as duplicate by Jakuje, user79743, mdpc, Scott, Community Jan 22 '16 at 19:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 6
    & ends the command, so you don't need the ; – user4443 Jan 21 '16 at 20:12
  • 1
    @drewbenn I don't see that it's a duplicate? – roaima Jan 21 '16 at 20:40
  • 1
    @drewbenn && doesn't (just) terminate a command; it separates two commands. & and ; are both terminators that don't explicitly require a subsequent command – roaima Jan 21 '16 at 21:19
  • Quote, quote, always quote: Use firefox '--new-tab' "$i/${i}"'.html&'; if you want to include the &. Use firefox '--new-tab' "$i/${i}"'.html' & (no ;) as the & already signals the end of the command. – user79743 Jan 21 '16 at 22:51

My solution requires that firefox is already running, if not, start it with firefox &. Then this script will open up the pages in tabs


for i in dir*; do
  firefox $i

I am using firefox 38.4.0

Not the answer you're looking for? Browse other questions tagged or ask your own question.