# Shell Scripting & Bash (DevOps) > 変数、ループ、条件分岐、関数、パイプ、リダイレクト - 20 面接問題 - Mid-Level - [面接問題: DevOps](https://sharpskill.dev/ja/technologies/devops/interview-questions.md) ## 1. Bash で変数を宣言する正しい構文は何ですか? **回答** Bash では、変数はドル記号なしで、等号の周りに空白を入れずに宣言します。変数名は文字またはアンダースコアで始まる必要があります。変数の値を使用するには、その名前にドル記号 ($) を前置します。等号の周りの空白は、Bash がそれらを別々のコマンド引数として解釈するため、構文エラーを引き起こします。 ## 2. Bash で USERNAME という名前の変数の値にアクセスするにはどうしますか? **回答** 変数の値にアクセスするには、その名前にドル記号 ($) を前置します。構文 $USERNAME は変数に格納された値を取得します。構文 ${USERNAME} も使用でき、特に連結や修飾子の使用において、より柔軟性を提供します。ドル記号がないと、Bash は USERNAME をリテラル文字列として解釈し、変数への参照として解釈しません。 ## 3. 子プロセスからアクセスできるように変数をエクスポートできるコマンドはどれですか? **回答** export コマンドは、環境変数を現在のシェルから起動されたすべての子プロセスで利用可能にします。export がないと、変数は現在のシェルにローカルであり、サブプロセスに渡されません。この区別は、他のスクリプトやプログラムを呼び出すスクリプトを書くときに重要です。export VAR=value で宣言と export を 1 行にまとめることができます。 ## さらに17問利用可能 - 最後に実行したコマンドの終了コードを取得するにはどうしますか? - Bash の if 条件の正しい構文は何ですか? 無料で登録: https://sharpskill.dev/ja/login ## その他のDevOps面接トピック - [バージョン管理 & Git](https://sharpskill.dev/ja/technologies/devops/interview-questions/version-control-git.md): 20問, Junior - [Linuxの基礎](https://sharpskill.dev/ja/technologies/devops/interview-questions/linux-fundamentals.md): 22問, Junior - [ネットワークの基礎](https://sharpskill.dev/ja/technologies/devops/interview-questions/networking-basics.md): 22問, Junior - [Docker の基礎](https://sharpskill.dev/ja/technologies/devops/interview-questions/docker-fundamentals.md): 24問, Junior - [CI/CDの基礎](https://sharpskill.dev/ja/technologies/devops/interview-questions/ci-cd-fundamentals.md): 18問, Junior - [GitHub Actions](https://sharpskill.dev/ja/technologies/devops/interview-questions/github-actions.md): 22問, Mid-Level - [GitLab CI/CD](https://sharpskill.dev/ja/technologies/devops/interview-questions/gitlab-ci.md): 22問, Mid-Level - [Jenkins](https://sharpskill.dev/ja/technologies/devops/interview-questions/jenkins.md): 22問, Mid-Level - [Kubernetesの基礎](https://sharpskill.dev/ja/technologies/devops/interview-questions/kubernetes-basics.md): 26問, Mid-Level - [Kubernetesネットワーキング](https://sharpskill.dev/ja/technologies/devops/interview-questions/kubernetes-networking.md): 24問, Mid-Level - [Kubernetes 上級](https://sharpskill.dev/ja/technologies/devops/interview-questions/kubernetes-advanced.md): 24問, Mid-Level - [Ingress & API Gateway](https://sharpskill.dev/ja/technologies/devops/interview-questions/ingress-api-gateway.md): 20問, Mid-Level - [Terraformの基礎](https://sharpskill.dev/ja/technologies/devops/interview-questions/terraform-basics.md): 22問, Mid-Level - [Terraform 上級](https://sharpskill.dev/ja/technologies/devops/interview-questions/terraform-advanced.md): 22問, Mid-Level - [Ansible & Configuration Management](https://sharpskill.dev/ja/technologies/devops/interview-questions/ansible-configuration.md): 20問, Mid-Level - [AWS の基礎](https://sharpskill.dev/ja/technologies/devops/interview-questions/aws-essentials.md): 26問, Mid-Level - [Azure の基礎](https://sharpskill.dev/ja/technologies/devops/interview-questions/azure-fundamentals.md): 22問, Mid-Level - [GCPの基礎](https://sharpskill.dev/ja/technologies/devops/interview-questions/gcp-fundamentals.md): 22問, Mid-Level - [モニタリングとPrometheus](https://sharpskill.dev/ja/technologies/devops/interview-questions/monitoring-prometheus.md): 22問, Mid-Level - [Logging & ELK Stack](https://sharpskill.dev/ja/technologies/devops/interview-questions/logging-elk.md): 20問, Mid-Level - [アラートとインシデント対応](https://sharpskill.dev/ja/technologies/devops/interview-questions/alerting-incident-response.md): 20問, Mid-Level - [Cloud Identity & Secrets](https://sharpskill.dev/ja/technologies/devops/interview-questions/cloud-identity-secrets.md): 22問, Mid-Level - [CI/CDパイプラインのセキュリティ](https://sharpskill.dev/ja/technologies/devops/interview-questions/cicd-pipeline-security.md): 20問, Mid-Level - [Helm & Kubernetes](https://sharpskill.dev/ja/technologies/devops/interview-questions/helm-kubernetes.md): 20問, Mid-Level - [ランタイム & クラスタセキュリティ](https://sharpskill.dev/ja/technologies/devops/interview-questions/runtime-cluster-security.md): 24問, Senior - [Container Supply Chain Security](https://sharpskill.dev/ja/technologies/devops/interview-questions/container-supply-chain.md): 22問, Senior - [Service MeshとIstio](https://sharpskill.dev/ja/technologies/devops/interview-questions/service-mesh-istio.md): 24問, Senior - [GitOps & ArgoCD](https://sharpskill.dev/ja/technologies/devops/interview-questions/gitops-argocd.md): 22問, Senior - [Progressive Delivery](https://sharpskill.dev/ja/technologies/devops/interview-questions/progressive-delivery.md): 20問, Senior - [分散オブザーバビリティ](https://sharpskill.dev/ja/technologies/devops/interview-questions/observability-distributed.md): 22問, Senior - [Disaster Recovery & Backup](https://sharpskill.dev/ja/technologies/devops/interview-questions/disaster-recovery.md): 20問, Senior - [パフォーマンス最適化](https://sharpskill.dev/ja/technologies/devops/interview-questions/performance-optimization.md): 22問, Senior - [クラウドコスト最適化](https://sharpskill.dev/ja/technologies/devops/interview-questions/infrastructure-cost.md): 20問, Senior - [SRE の原則](https://sharpskill.dev/ja/technologies/devops/interview-questions/sre-principles.md): 24問, Senior - [Chaos Engineering](https://sharpskill.dev/ja/technologies/devops/interview-questions/chaos-engineering.md): 20問, Senior - [Platform Engineering](https://sharpskill.dev/ja/technologies/devops/interview-questions/platform-engineering.md): 22問, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ja/technologies/devops/interview-questions/shell-scripting-bash