• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

How To Use case in Bash Script, Example

May 15, 2011 by Sharad Chhetri Leave a Comment

How To Use case in Bash Script, Example

This is only an example.

#/bin/bash
echo "Give Full Path where the file is located"
read pth
echo "Give the file name"
read fle
if [ -f $pth/$fle ];then
echo "$fle file is found in $pth"
else
echo "$fle file not found in $pth"
echo "U r going to exit in 2seconds"
sleep 2
exit
fi

echo "Do u want to delete the file (Y/N)"
read xyz
case $xyz in
Y|y) rm -fr $pth/$fle;;
[Yy][Ee][Ss]) rm -fr $pth/$fle;;
N|n) exit;;
[Nn][Oo]) exit;;
*) exit;;
esac

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. How to Use Expect In Bash Script
  2. How To Use opt In Bash Script
  3. Set and reset user password by bash script
  4. send email after mysql backup through bash script in simple way
  5. Xen Server License Nagios Plugin (bash script)
  6. Nagios plugin check_mailfromd bash script
  7. MySQL backup bash script
  8. Replace keyword with its filename without extension : bash script
  9. Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)
  10. bash scripting : Prompt user yes / no for confirmation

Filed Under: Linux Tagged With: bash script

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

Save iptables permanently on Ubuntu

Allow only members of Wheel group to use su command on RHEL/CentOS

How to extract RPM package on Linux system

How To Get SSH Public Key Fingerprint Information

How to test rpm package before installation

yum : how to find rpm package which has certain command or file

How to know last command run successfully : Linux / Unix

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

How to change hostname in Ubuntu 12.04 and 12.10 without system restart

How to change login banner message in GUI mode in CentOS 6 or above version.

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Error: Could not stat() command file ‘/var/lib/nagios3/rw/nagios.cmd’!

How to zip directory in linux explained with examples

Non interactive ,without typing password do ssh to Server : By sshpass

configure: error: C++ compiler cannot create executables

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

Linux basic command

Linux Basic Commands For Every Beginner

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy