Shell - Enter or put program into variable

Asked

Viewed 24 times

0

I have the following code:

for (( c=1; c<=10; c++ ))
do
  cc stringalea.c -o st
  aux = ./st $c
  echo $aux
  ...
done

The stringalea. c program returns a pseudo-random word of length "c". How do I enter the aux variable, the output of the executable ". /st $c"?

  • Use the command substitution: https://answall.com/q/327578/112052

  • aux=$(echo ./st $c ) writes in aux ". / st 1"

  • No, it’s just aux=$(./st $c)

  • Another thing, you need to compile the stringalea program. c all the time? Isn’t it better to compile once only before the for?

  • I’ll change thanks already

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.