Problem printing variable on terminal

0 votes

I am using the following code on Ubuntu terminal:

#echo 2
2
# x=2
#echo x

Expected output is 2 but it is printing x.

Feb 18 in Linux Administration by Raghav
32 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You are basically trying to echo the value stored in the variable x. But when you run "echo x" you are telling the system to echo the character x. To print the value, you have to use the dollar sign to inform the system that it is a variable. This should work:

# echo $x
answered Feb 18 by Omkar
• 65,850 points

Related Questions In Linux Administration

0 votes
1 answer

To run a shell script on a Unix console or Mac terminal

To run a non-executable sh script, use: sh myscript To run ...READ MORE

answered May 16 in Linux Administration by Upasana
• 7,680 points
10 views
0 votes
2 answers

How do I find all files containing specific text on Linux?

grep -rnw 'text to find recursively inside ...READ MORE

answered 5 days ago in Linux Administration by Ritesh Singh
1,369 views
0 votes
1 answer

Create new user on Ubuntu

Hey @Eric,  Follow these steps: Go to your terminal  Execute ...READ MORE

answered Jan 10 in Linux Administration by Noah
50 views
0 votes
1 answer

"connect: Network is unreachable?" error on ping

You need to set your default gateway. ...READ MORE

answered Jan 23 in Linux Administration by Tina
62 views
0 votes
1 answer
+1 vote
2 answers

Execute Pig Script from Grunt Shell

From your current directory run  pig -x local Then ...READ MORE

answered Oct 25, 2018 in Big Data Hadoop by Kunal
475 views
0 votes
1 answer

How to stop messages from being displayed on spark console?

In your log4j.properties file you need to ...READ MORE

answered Apr 24, 2018 in Apache Spark by kurt_cobain
• 9,260 points
624 views
0 votes
1 answer

How to get Spark dataset metadata?

There are a bunch of functions that ...READ MORE

answered Apr 26, 2018 in Apache Spark by kurt_cobain
• 9,260 points
177 views
+2 votes
2 answers

Ubuntu installing problem

Hey Prince! This seems to be like a ...READ MORE

answered Oct 15, 2018 in Linux Administration by Omkar
• 65,850 points

edited Oct 15, 2018 by Kalgi 37 views
+1 vote
1 answer

Not able to install npm on Ubuntu

Try installing npm using aptitude: sudo apt install aptitude sudo ...READ MORE

answered Nov 28, 2018 in Linux Administration by Omkar
• 65,850 points
894 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.