I'm writing a bash script to format my partitions. One of the commands I want to run is the following:
mkfs.btrfs -f -m single -L root /dev/sda1
So I have split that command into the options part: -f -m single -L root
and the partition part: /dev/sda1
and put them into variables like this:
mkfs.btrfs "${myoptions}" /dev/"${mypartition}"
but it fails with:
mkfs.btrfs: invalid option -- ´ ´
I have tried different variations of it like putting the 2 parts in doubles quotes but all fails. I have also tried to put the two parts into an array and run it like this:
mkfs.btrfs "${array[1]}" "${array[2]}"
or like this:
mkfs.btrfs "${array[*]}"
but it also fails.
If I run it without the options part it works, so my guess is that the issue comes from the empty space between the two arguments but I don't know how to solve it.