0

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

The file structure is

dir1/dir1.html
dir2/dir2.html
dir3/dir3.html

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?

  • 6
    & ends the command, so you don't need the ; –  Jan 21 '16 at 20:12
  • 1
    @drewbenn I don't see that it's a duplicate? – Chris Davies 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 – Chris Davies 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. –  Jan 21 '16 at 22:51

1 Answers1

-1

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

#!/bin/sh

for i in dir*; do
  firefox $i
done

I am using firefox 38.4.0

Will M
  • 14