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, 2019 in Linux Administration by Raghav
386 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, 2019 by Omkar
• 69,210 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, 2019 in Linux Administration by Upasana
• 8,620 points
598 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, 2019 in Linux Administration by Upasana
• 8,620 points
7,721 views
0 votes
0 answers

How to change default integreated terminal in VS Code to kitty, on Linux?

I'm using kitty (it's a terminal) on ...READ MORE

Apr 26, 2022 in Linux Administration by Edureka
• 13,670 points
973 views
0 votes
1 answer

bash terminal on kubuntu

You are actually using a bash terminal. ...READ MORE

answered Jun 7, 2022 in Linux Administration by Korak
• 5,820 points
423 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
5,654 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,390 points
5,010 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,390 points
4,417 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
• 69,210 points

edited Oct 15, 2018 by Kalgi 945 views
+2 votes
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
• 69,210 points
7,692 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP