1

I have a function called fslnvols which gives the number of images in a 4D image.

Usage:

fslnvols <input>

I wanted to save the output of the function to variable A,so I tried:

A=fslnvols inputimage

and

fslnvols inputimage

A=$(fslnvols)

but I didn't get the wanted result, any idea how to fix it?

1
  • 1
    "but none of them worked" what does that mean? var=$(foo) will store the stdout of the foo command in $var. Commented Jul 3, 2017 at 4:55

1 Answer 1

2

Use command substitution, $():

A=$(fslnvols inputimage)

The command whose output you want to store as variable A, goes inside $() -- fslnvols inputimage in this case.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.