shell - how to append string -


i parsing file selected string , build single line, however, don't know how it(as shown in //add...) in shell scripts

while read line     tt=`echo $line | cut -d'|' -f2 | cut -d'"' -f1`     //add $total = add tt parts big string seperate ", " done < tmp_file  echo $total >> outfile 

thank you

you append in shell using assignment , variable expansion:

total="${total}, ${tt}" 

the curly braces ({}) aren't necessary in case find distinguish variables when they're next each other this.

this give leading ", ". can work around this:

total="${total:+${total}, }${tt}" 

the ${variable:+value} construct expands value if variable set.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -