bash append to string code example

Example 1: bash how to append stdout to a file

# Basic syntax:
command >> output_file # Append stdout to output_file

# Note, use > to overwrite file contents and >> to append to a file
# Note, if the output_file doesn't exist, it will be created

Example 2: combine strings bash

foo="Hello"
foo="${foo} World"
echo "${foo}"
> Hello World

Example 3: append string perl

$name = checkbook'; 
$filename = '/tmp/' . $name . '.tmp'; -this line-

# $filename now contains "/tmp/checkbook.tmp"

Example 4: sh concat string

VAR1="Hello,"
VAR2=" World"
VAR3="$VAR1$VAR2"
echo "$VAR3"