Passing values to Bash script

Let's say I have a matlab file that calculates some values, giving:
alpha = 7
beta = 9
Now, I want to pass these values to a Bash script for use.
What is the syntax for doing this?

 Respuesta aceptada

Walter Roberson
Walter Roberson el 17 de Mzo. de 2019

0 votos

Example:
cmd = sprintf('alpha=%d beta=%d ls | head -$beta | tail -$alpha', alpha, beta);
system(cmd)

3 comentarios

g
g el 17 de Mzo. de 2019
Thanks! What do head and tail do? What if I desire to pass a third variable?
cmd = sprintf('first_variable=%d second_variable=%d third_variable=%d command to execute goes here and refers to $first_variable and $second_variable and $third_variable', first_var, second_var, third_var)
cameron morrison
cameron morrison el 5 de Mzo. de 2020
i can't seem to get this to work at all. Is there anything I have to write on the Linux command line?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

g
g
el 17 de Mzo. de 2019

Comentada:

el 5 de Mzo. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by