Learning-Ocean
  • Ansible
  • Docker
  • Kubernetes
  • Docker-Compose
  • Docker-Swarm
  • Terraform
  • Shell Script
  • Subscribe
  • About Us
Shell Script
  • shell script tutorial
  • first shell script file
  • shebang
  • shell built-in and commands
  • print
  • comments and escape
  • user define variables
  • system variable
  • input
  • command line arguments
  • assign a command's output
  • read only variable
  • convert a string
  • substring
  • set default value
  • arithmetic operations
  • functions
  • parameters to a function
  • local variable
  • return status and test
  • if with command
  • if with numbers
  • if with string
  • if with files
  • not operator
  • and operator
  • or operator
  • if-else
  • nested if else
  • elif
  • case
  • while loop
  • read file
  • until
  • for loop
  • [email protected] and $*
  • select
  • continue
  • break
  • nested loop
  • project files

How to create a read-only variable in Shell Script


We can create read-only variable in shell script using readonly.

syntax:

$ readonly VARIABLE_NAME


let's take below example.

 #!/bin/bash
name="hinal"
# readonly name
echo "${name}"
unset name
# name="gaurav"
echo "${name}"





PreviousNext