String Concatenation in bash with space and putting quote around -


i got response in last question. idea process n number of inputs command line, save first 9 variables , make string 10 onward.

i found easiest solution.

var1="$1" var2="$2" var3="$3" var4="public" var5="$5" var6="''" var7="$7" var8="$8" var9="$9" var10="$(shift 9; ifs=""; echo "$*")"  echo snmptrap $var1 $var2 $var3  $var4 $var5 $var6 $var7 $var8 $var9 "$var10"  snmptrap $var1 $var2 $var3  $var4 $var5 $var6 $var7 $var8 $var9 "$var10" 

the output looks this...

./snmptas  -v 2c -c "" 9.48.85.57 "" 1.3.6.1.4.1.2.6.201.3 s s  abc ddef efff  snmptrap -v 2c -c public 9.48.85.57 '' 1.3.6.1.4.1.2.6.201.3 s s abcddefefff 

but wanted $var10 in form

"abc ddef efff".

this needs changed. it's taking spaces off.

var10="$(shift 9; ifs=""; echo "$*")" 

how can make var10 = "abc ddef efff"?

thanks

a subshell echo not appropriate there. better way:

shift 9 var10="$*" 

if want quotes around part of value, change last line to:

var10=\""$*"\" 

unrelated that, i'm wondering if treatment var6 intended. suspect closer intended:

snmptrap $var1 $var2 $var3  $var4 $var5 '' $var7 $var8 $var9 "$var10" 

or this:

var6= snmptrap $var1 $var2 $var3  $var4 $var5 "$var6" $var7 $var8 $var9 "$var10" 

but if guess wrong , original treatment working intended never mind, ignore these remarks.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -