Solved

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

Posted on 2010-09-18
9
321 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sendmail STARTTLS error 37 79
Linux  Script File Attributes 5 52
Setting up Two Three NICs with One on a Different Subnet 22 57
mcrypt_create_iv() is deprecated 4 69
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
​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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

911 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

18 Experts available now in Live!

Get 1:1 Help Now