user3699906
user3699906

Reputation: 1

how to concatenate all inputs including whitepaces to one string?

for a script

script.sh < a b                              c a

I want to put the inputs in one string, like that

string=" a b                              c a"

ie, preserve the spaces

how can i do that?

thanks

Upvotes: 0

Views: 51

Answers (1)

konsolebox
konsolebox

Reputation: 75558

Consider using here documents and here strings.

script.sh:

#!/bin/bash
readarray -t INPUT
printf "input: %s\n" "${INPUT[@]}"

example:

bash script.sh <<< "a b c"

Upvotes: 1

Related Questions