Home »
Linux »
Linux shell script programs
Linux shell script program to create and print the value of variables
By IncludeHelp Last updated : October 20, 2024
Problem statement
Here, we will create a shell script program to create two variables and then print values of variables on the console screen.
Linux shell script program to create and print the value of variables
The source code to create a Linux shell script program to create and print the value of variables is given below. The given program is compiled and executed successfully on Ubuntu 20.04.
#!/bin/bash
# Program name: "printVar.sh"
# Linux shell script program to create and print the value of variables.
country="India"
year=2021
echo "Country name: $country"
echo "Year: $year"
Output
$ sh printVar.sh
Country name: India
Year: 2021
Explanation
Here, we created two variables country, year. which are initialized with "India", 2021 respectively. After that, we printed the value of variables on the console screen using echo command.
Linux shell script programs »