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
40 views

1 answer to this question.

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
• 67,540 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,530 points
45 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,530 points
32 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
4,731 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
131 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
775 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,240 points
1,070 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,240 points
367 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
• 67,540 points

edited Oct 15, 2018 by Kalgi 51 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
• 67,540 points
1,617 views