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
• 66,910 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
• 8,170 points
21 views
0 votes
1 answer

Ubuntu 10.10: Connecting to a terminal to a serial-to-USB device on Maverick Meerkat

Check with dmesg | grep tty if system recognize ...READ MORE

answered Jun 10 in Linux Administration by Upasana
• 8,170 points
11 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 May 20 in Linux Administration by Ritesh Singh
2,072 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
65 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
554 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
726 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
227 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
• 66,910 points

edited Oct 15, 2018 by Kalgi 40 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
• 66,910 points
1,074 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.