Why does this command for qsub to submit multiple pbs scripts work in the bash shell but not fish?

145 Views Asked by At

I have a bunch of .pbs files in one directory.

I can qsub the files no problem with this command in the bash shell but for the fish shell, I continuously hit enter and it just creates a new input line. Any ideas why it doesn't work in fish?

for file in *.pbs; do qsub $file; done

1

There are 1 best solutions below

0
faho On BEST ANSWER

Fish's syntax for loops and other block constructs is different.

In this case it's

for file in *.pbs
    qsub $file
end

or, on one line:

for file in *.pbs; qsub $file; end

Other looping constructs look similar - no introductory "do" and they end with "end".

Other differences here: This behaves like bash with the nullglob option, so if no file matches the for-loop simply won't be executed, there's no need to guard for a literal *.pbs being passed.

Also the $file doesn't need to be quoted because it's set as one element and so it will be passed as one element, no word splitting takes place.

Fish uses a different script syntax from bash and other shells. To read up on it: Fish for bash users is the quick starting point, but the rest of the documentation is worth reading (in my, admittedly biased, opinion).