adding strings in bash
Here's my problem.
#!/bin/bash $APE=ape $BEAR=bear $APEBEAR=$APE + $BEAR <--- will not work how do you do this? I can't seem to find how to add two strings??? |
+ is a java string operator not a bash script operator
Try #!/bin/bash APE=ape BEAR=bear APEBEAR=`echo $APE $BEAR` echo $APEBEAR |
Okay but that would yield: "ape bear" as result, not "apebear"
|
nevermind, found it after all:
APE=ape BEAR=bear APEBEAR=$APE$BEAR |
OT, but it's better to use enclosing quotes or braces to shield your variables from breaking (due to you shell's ${IFS}): APEBEAR=${APE}${BEAR}.
|
All times are GMT -5. The time now is 02:56 AM. |