Solved

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

Posted on 2010-09-18
9
308 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
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
 

Author Comment

by:sobeservices2
ID: 33708901
Could I echo several lines like that without using quotes?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
​Being a Managed Services Provider (MSP) has presented you  with challenges in the past— and by meeting those challenges you’ve reaped the rewards of success.  In 2014, challenges and rewards remain; but as the Internet and business environment evol…
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.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now