Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k
edited body
Source Link
Username
  • 899
  • 6
  • 21
  • 40

My bash script:

#!bin/bash
MY_ARRAY=("Some string" "Another string")
function join { local IFS="$1"; shift; echo -e "$*"; }
join "," ${MY_ARRAY[@]}

I want the output to be: Some string.,Another string.

Instead, I get Some,string.,Another,string.

What must I change to get the result I want?

My bash script:

#!bin/bash
MY_ARRAY=("Some string" "Another string")
function join { local IFS="$1"; shift; echo -e "$*"; }
join "," ${MY_ARRAY[@]}

I want the output to be: Some string.Another string.

Instead, I get Some,string.Another,string.

What must I change to get the result I want?

My bash script:

#!bin/bash
MY_ARRAY=("Some string" "Another string")
function join { local IFS="$1"; shift; echo -e "$*"; }
join "," ${MY_ARRAY[@]}

I want the output to be: Some string,Another string.

Instead, I get Some,string,Another,string.

What must I change to get the result I want?

Source Link
Username
  • 899
  • 6
  • 21
  • 40

How do I join an array of strings where each string has spaces?

My bash script:

#!bin/bash
MY_ARRAY=("Some string" "Another string")
function join { local IFS="$1"; shift; echo -e "$*"; }
join "," ${MY_ARRAY[@]}

I want the output to be: Some string.Another string.

Instead, I get Some,string.Another,string.

What must I change to get the result I want?