I am pretty sure that this is a very basic question, but I am not able to solve it after trying for a long time.
How to store a return value of a function in a variable?
I am trying to execute iconv function. And I have tried with this:
my_var=$(iconv -f UTF-8 -t UTF-8 < sample-feed-utf16.xml > con_sample-feed-utf16.xml)
The function executes, but the return value is not stored in my_var. Can anyone help me with this?
You are redirecting the output to a file, so nothing is going to go into the variable.
If you want to store the exit code, you can do it like this: