How to generate a for loop to cat a command?

131 Views Asked by At

I need to run a program called Bppancestor, in order to do so you use:

bppancestor param="configuration_file"

I need to run the program per all the .conf files inside a directory and I thought that a for loop could help.

I tried the following:

for f in *.conf; do "bppancestor param=$f"; done


I thought this would work but the results are:

bppancestor param=sim99_scaled_tree_4.924.nwk_alpha1.23061333143822.conf: command not found

But if I ran it separetely it works.

How could I solve this?

1

There are 1 best solutions below

1
On

The double quotes cause Bash to understand everything between them as one argument - and you probably don't have command called "bppancestor param=file.conf".

You want to make sure the double quote only the one thing that should be considered one argument.

Now - specifically for your case where the conf file can never have spaces in their name, you probably shouldn't have used double quotes in the first place: contrary to popular belief it is not a good idea to double quote everything always everywhere - use double quotes judicially where you know you'd need it, or you are uncertain whether you can verify that you don't need it. Too much double quotes make reading hard and cause these kind of issues all the time.