[CentOS] Bash question

Jerry Geis jerry.geis at gmail.com
Fri Jul 6 13:18:37 UTC 2018


Hi All,

I am trying to build a command line with spaces in the argument. This
demonstrates what I am trying to do. Clearly the first two commands work
fine. However, the last 4 lines to not.

/opt/libreoffice5.4/program/soffice.bin --headless --convert-to csv
"/tmp/file.xlsx"
/opt/libreoffice5.4/program/soffice.bin --headless --convert-to csv
"/tmp/file 2.xlsx"

MSG="file 2"
MSG="csv \"$MSG\""
echo $MSG
/opt/libreoffice5.4/program/soffice.bin --headless --convert-to $MSG

I am trying to make a variable containing spaces which is MSG. Then add to
that variable the argument csv.  The "echo" above prints the write stuff.
But when I try to use it in the last command its no longer valid and says
Source file could not be loaded.

What am I missing?  much searching hinted to arrays and using \$ but I
could not get that to work.

Thanks.

Jerry



More information about the CentOS mailing list