I want output as $msg1 two three. No space between $ and msg1. How it possible?
#!/bin/sh
msg1=$
ms="$msg1 msg1"
msg2="$ms two"
msg3="$msg2 three"
echo $msg3
3 Answers
You can use:
msg1='$'
ms="${msg1}msg1"
msg2="$ms two"
msg3="$msg2 three"
echo "$msg3"
OUTPUT:
$msg1 two three
PS: Take note of ${msg1} syntax to create variable boundary around msg1. This is used to avoid it making it $msg1msg1
Pretty simple:
Input:
echo '$msg1' two three
(note the single quotes)
Output:
$msg1 two three