Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

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
0
sobeservices2
Asked:
sobeservices2
1 Solution
 
savoneCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now