• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • 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
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

 
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

Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

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