How do I echo a command that has a $1 in it

I would like to echo these lines of text but I have an issue that it won't display the dollar sign in it

Hello World
The apples are $2 a piece
could you please by me $4 worth
sobeservices2Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
savoneConnect With a Mentor Commented:
echo The apples are \$2 a piece

0
 
sobeservices2Author Commented:
Thanks guys I eneded up figuring it out right after I posted the question
0
Improved Protection from Phishing Attacks

WatchGuard DNSWatch reduces malware infections by detecting and blocking malicious DNS requests, improving your ability to protect employees from phishing attacks. Learn more about our newest service included in Total Security Suite today!

 
sobeservices2Author Commented:
Could I echo several lines like that without using quotes?
0
 
rumi78Commented:
echo -e The apples are \$2 a piece\\nThe apples are \$2 a piece\\nThe apples are \$2 a pieceecho -e The apples are \$2 a piece\\nThe apples are \$2 a piece\\nThe apples are \$2 a piece

rgds
rumi
0
 
TintinCommented:
For several lines, it's easier to do
cat <<'EOF'
The apples are $2 each
The oranges are $1 each
EOF

Open in new window

0
 
savoneCommented:
Several lines like this:

$ echo -e "The apples are \$2 a piece\nNew line"
The apples are $2 a piece
New line
$

0
 
savoneCommented:
\n = newline

Sorry, I should have mentioned that
0
 
jghelfman40Commented:
why use $2 at all?

read $1
echo $REPLY


$REPLY variable is set to what $1 input is.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.