# Shell Scripting & Bash (DevOps) > Variables, loops, conditionals, functions, pipes, redirections - 20 interview questions - Mid-Level - [Interview Questions: DevOps](https://sharpskill.dev/en/technologies/devops/interview-questions.md) ## 1. What is the correct syntax to declare a variable in Bash? **Answer** In Bash, a variable is declared without the dollar sign and without spaces around the equals sign. The variable name must start with a letter or underscore. To use the variable's value, prefix its name with the dollar sign ($). Spaces around the equals sign cause a syntax error because Bash interprets them as separate command arguments. ## 2. How to access the value of a variable named USERNAME in Bash? **Answer** To access a variable's value, prefix its name with the dollar sign ($). The syntax $USERNAME retrieves the value stored in the variable. The syntax ${USERNAME} can also be used, which offers more flexibility, especially for concatenation or using modifiers. Without the dollar sign, Bash interprets USERNAME as a literal string and not as a variable reference. ## 3. Which command allows exporting a variable to make it accessible to child processes? **Answer** The export command makes an environment variable available to all child processes launched from the current shell. Without export, a variable is local to the current shell and is not passed to subprocesses. This distinction is crucial when writing scripts that invoke other scripts or programs. It is possible to combine declaration and export in one line with export VAR=value. ## 17 more questions available - How to capture the exit code of the last executed command? - What is the correct syntax for an if condition in Bash? Sign up for free: https://sharpskill.dev/en/login ## Other DevOps interview topics - [Version Control & Git](https://sharpskill.dev/en/technologies/devops/interview-questions/version-control-git.md): 20 questions, Junior - [Linux Fundamentals](https://sharpskill.dev/en/technologies/devops/interview-questions/linux-fundamentals.md): 22 questions, Junior - [Networking Basics](https://sharpskill.dev/en/technologies/devops/interview-questions/networking-basics.md): 22 questions, Junior - [Docker Fundamentals](https://sharpskill.dev/en/technologies/devops/interview-questions/docker-fundamentals.md): 24 questions, Junior - [CI/CD Fundamentals](https://sharpskill.dev/en/technologies/devops/interview-questions/ci-cd-fundamentals.md): 18 questions, Junior - [GitHub Actions](https://sharpskill.dev/en/technologies/devops/interview-questions/github-actions.md): 22 questions, Mid-Level - [GitLab CI/CD](https://sharpskill.dev/en/technologies/devops/interview-questions/gitlab-ci.md): 22 questions, Mid-Level - [Jenkins](https://sharpskill.dev/en/technologies/devops/interview-questions/jenkins.md): 22 questions, Mid-Level - [Kubernetes Basics](https://sharpskill.dev/en/technologies/devops/interview-questions/kubernetes-basics.md): 26 questions, Mid-Level - [Kubernetes Networking](https://sharpskill.dev/en/technologies/devops/interview-questions/kubernetes-networking.md): 24 questions, Mid-Level - [Kubernetes Advanced](https://sharpskill.dev/en/technologies/devops/interview-questions/kubernetes-advanced.md): 24 questions, Mid-Level - [Ingress & API Gateway](https://sharpskill.dev/en/technologies/devops/interview-questions/ingress-api-gateway.md): 20 questions, Mid-Level - [Terraform Basics](https://sharpskill.dev/en/technologies/devops/interview-questions/terraform-basics.md): 22 questions, Mid-Level - [Terraform Advanced](https://sharpskill.dev/en/technologies/devops/interview-questions/terraform-advanced.md): 22 questions, Mid-Level - [Ansible & Configuration Management](https://sharpskill.dev/en/technologies/devops/interview-questions/ansible-configuration.md): 20 questions, Mid-Level - [AWS Essentials](https://sharpskill.dev/en/technologies/devops/interview-questions/aws-essentials.md): 26 questions, Mid-Level - [Azure Fundamentals](https://sharpskill.dev/en/technologies/devops/interview-questions/azure-fundamentals.md): 22 questions, Mid-Level - [GCP Fundamentals](https://sharpskill.dev/en/technologies/devops/interview-questions/gcp-fundamentals.md): 22 questions, Mid-Level - [Monitoring & Prometheus](https://sharpskill.dev/en/technologies/devops/interview-questions/monitoring-prometheus.md): 22 questions, Mid-Level - [Logging & ELK Stack](https://sharpskill.dev/en/technologies/devops/interview-questions/logging-elk.md): 20 questions, Mid-Level - [Alerting & Incident Response](https://sharpskill.dev/en/technologies/devops/interview-questions/alerting-incident-response.md): 20 questions, Mid-Level - [Cloud Identity & Secrets](https://sharpskill.dev/en/technologies/devops/interview-questions/cloud-identity-secrets.md): 22 questions, Mid-Level - [CI/CD Pipeline Security](https://sharpskill.dev/en/technologies/devops/interview-questions/cicd-pipeline-security.md): 20 questions, Mid-Level - [Helm & Kubernetes](https://sharpskill.dev/en/technologies/devops/interview-questions/helm-kubernetes.md): 20 questions, Mid-Level - [Runtime & Cluster Security](https://sharpskill.dev/en/technologies/devops/interview-questions/runtime-cluster-security.md): 24 questions, Senior - [Container Supply Chain Security](https://sharpskill.dev/en/technologies/devops/interview-questions/container-supply-chain.md): 22 questions, Senior - [Service Mesh & Istio](https://sharpskill.dev/en/technologies/devops/interview-questions/service-mesh-istio.md): 24 questions, Senior - [GitOps & ArgoCD](https://sharpskill.dev/en/technologies/devops/interview-questions/gitops-argocd.md): 22 questions, Senior - [Progressive Delivery](https://sharpskill.dev/en/technologies/devops/interview-questions/progressive-delivery.md): 20 questions, Senior - [Distributed Observability](https://sharpskill.dev/en/technologies/devops/interview-questions/observability-distributed.md): 22 questions, Senior - [Disaster Recovery & Backup](https://sharpskill.dev/en/technologies/devops/interview-questions/disaster-recovery.md): 20 questions, Senior - [Performance Optimization](https://sharpskill.dev/en/technologies/devops/interview-questions/performance-optimization.md): 22 questions, Senior - [Cloud Cost Optimization](https://sharpskill.dev/en/technologies/devops/interview-questions/infrastructure-cost.md): 20 questions, Senior - [SRE Principles](https://sharpskill.dev/en/technologies/devops/interview-questions/sre-principles.md): 24 questions, Senior - [Chaos Engineering](https://sharpskill.dev/en/technologies/devops/interview-questions/chaos-engineering.md): 20 questions, Senior - [Platform Engineering](https://sharpskill.dev/en/technologies/devops/interview-questions/platform-engineering.md): 22 questions, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/en/technologies/devops/interview-questions/shell-scripting-bash