---
title: "Discussion on \"Shell Scripting Scenarion Based Question and Answer\" | Hashnode"
description: "Discussion on \"Shell Scripting Scenarion Based Question and Answer\". Q1: How can you write a shell script to check if a file exists and display its content if it does?\nAns: You can achieve this using conditional statements and file handling in shell scripting. Here's an example:\n#!/bin/bash\n\nfilename=\"example.txt\"\n\nif..."
url: "https://hashnode.com/posts/shell-scripting-scenarion-based-question-and-answer/6463efad07fa002cb394cf20"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Shell Scripting Scenarion Based Question and Answer](https://aakashbhatt04.hashnode.dev/shell-scripting-scenarion-based-question-and-answer?utm_source=hashnode&utm_medium=feed)

Q1: How can you write a shell script to check if a file exists and display its content if it does? Ans: You can achieve this using conditional statements and file handling in shell scripting. Here's an example: #!/bin/bash filename="example.txt" if...

May 16, 2023 · 4 min read · aakashbhatt04.hashnode.dev  
Read the article

-   [#devops](https://hashnode.com/tag/devops)
-   [#shell-script](https://hashnode.com/tag/shell-script)

## Written by

[Aakash Bhatt](https://hashnode.com/@aakashbhatt04)

@aakashbhatt04

  
[View profile](https://hashnode.com/@aakashbhatt04)

DevOps practitioner

## Responses 1

Markdown supported · ⌘↵ to post

[HIMANSHU SRIVASTAVA](https://hashnode.com/@himanshurkt96)

[May 16, 2023](https://hashnode.com/posts/shell-scripting-scenarion-based-question-and-answer/6463efad07fa002cb394cf20/comment/6463f013a53e44b8a30bf5f9)

Informative
