Solved

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

Posted on 2010-09-18
9
361 Views
Last Modified: 2012-05-10
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
Comment
Question by:sobeservices2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 23

Accepted Solution

by:
savone earned 500 total points
ID: 33708826
echo The apples are \$2 a piece

0
 
LVL 23

Expert Comment

by:savone
ID: 33708830
0
 

Author Comment

by:sobeservices2
ID: 33708899
Thanks guys I eneded up figuring it out right after I posted the question
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:sobeservices2
ID: 33708901
Could I echo several lines like that without using quotes?
0
 
LVL 7

Expert Comment

by:rumi78
ID: 33709001
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
 
LVL 48

Expert Comment

by:Tintin
ID: 33709032
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
 
LVL 23

Expert Comment

by:savone
ID: 33709069
Several lines like this:

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

0
 
LVL 23

Expert Comment

by:savone
ID: 33709071
\n = newline

Sorry, I should have mentioned that
0
 
LVL 6

Expert Comment

by:jghelfman40
ID: 33709878
why use $2 at all?

read $1
echo $REPLY


$REPLY variable is set to what $1 input is.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question