• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to create a word replacing Bash script on Ubuntu 21.04

  • 00:43 lsb_release -a
  • 00:53 vim test
  • 01:10 vim sample.sh
  • 06:18 chmod +x sample.sh
  • 06:30 ls -la sample.sh
  • 06:39 sh sample.sh
6859

To Create a word replacing Bash script on Ubuntu 21.04

Introduction:

The bash shell program was written by Brian Fox as an upgraded version of Bourne Shell's sh program. Bash provides the ability to view or modify the readline key bindings with the bind built-in command.

Installation Procedure:

Step 1: Check the OS version by using the below command

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 21.04
Release:	21.04
Codename:	hirsute

Step 2: Creating a sample content file by using the below command

root@linuxhelp:~# vim test

Unix was Powerfull
Unix was close source
Unix  trademarked as Unix was a family of multitasking,
 multiuser computer
operating systems that derive from the original AT&T Unix,
whose development started in 1969

Step 3: Create the word replacing Bash Script by using the below command

root@linuxhelp:~# vim sample.sh
#!/bin/bash


while true; do

echo "Enter the File Name"

read var1

echo "Select the Pattern"

read var2


echo "Select the Replacing Pattern"

read var3

echo "Working Please Wait"


sed -i s/$var2/$var3/g $var1


cat $var1

echo 



read -p "Do you wish to run this program again?, Press y for yes and n for NO  " y

 case $y in

        [Yy]* ) sh sample.sh ;;

        [Nn]* )

        echo

        echo "Process Completed"


        echo "Bye"


        exit ;;


         esac

done

Step 4: Give Execute Permission to the Script file by using the below command

root@linuxhelp:~# chmod +x sample.sh

Step 5: View the Permissions by using the below command

root@linuxhelp:~# ls -la sample.sh 
-rwxr-xr-x 1 root root 451 Jan 21 06:33 sample.sh

Step 6: Execute the Script file by using the below command

root@linuxhelp:~# sh sample.sh 
Enter the File Name
test
Select the Pattern
Unix
Select the Replacing Pattern
Linux
Working Please Wait
Linux was Powerfull
Linux was close source
Linux  trademarked as Linux was a family of multitasking,
 multiuser computer
operating systems that derive from the original AT&T Linux,
whose development started in 1969

Do you wish to run this program again?, Press y for yes and n for NO  y
Enter the File Name
test
Select the Pattern
Linux
Select the Replacing Pattern
Unix
Working Please Wait
Unix was Powerfull
Unix was close source
Unix  trademarked as Unix was a family of multitasking,
 multiuser computer
operating systems that derive from the original AT&T Unix,
whose development started in 1969

Do you wish to run this program again?, Press y for yes and n for NO  n

Process Completed
Bye

With this the process of creating a word replacing Bash script on Ubuntu 21.04 has come to an end.

Tags:
connor
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What is an acronym of Bash?

A

The acronym of Bash is Bourne Again Shell, a punning name, which is a tribute to Bourne Shell

Q

What is the difference between SH and Bash?

A

Bash is a sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh)

Q

What is the Bash manual?

A

This manual is meant as a brief introduction to features found in Bash. The Bash manual page should be used as the definitive reference on shell behavior.

Q

Which Shell has Bash borrowed concepts from other shells?

A

Bash has borrowed concepts from are the Bourne Shell ( sh ), the Korn Shell ( ksh ), and the C-shell ( csh and its successor, tcsh )

Q

What is bash script in Linux?

A

The default command language of Linux is a Bash script. We need to run many commands in Linux on a daily basis for many purposes.

Related Tutorials in How to create a word replacing Bash script on Ubuntu 21.04

Related Tutorials in How to create a word replacing Bash script on Ubuntu 21.04

How to install Meld tool in Ubuntu
How to install Meld tool in Ubuntu
Feb 25, 2017
How to install Dconf-Editor on Ubuntu 18.04
How to install Dconf-Editor on Ubuntu 18.04
Jul 14, 2018
How to install and update OpenSSL on Ubuntu 16.04
How to install and update OpenSSL on Ubuntu 16.04
Mar 9, 2017
How to install GLib 2.0 on Ubuntu 17.04
How to install GLib 2.0 on Ubuntu 17.04
May 22, 2017
How to Install Android Emulator on Ubuntu 20.4.1
How to Install Android Emulator on Ubuntu 20.4.1
Jul 13, 2021
How To Install AnyDesk on Ubuntu 16.04
How To Install AnyDesk on Ubuntu 16.04
Apr 4, 2018
How to install Genymotion 2.12.1 on Ubuntu 18.04
How to install Genymotion 2.12.1 on Ubuntu 18.04
Jul 9, 2018
How to install Timeshift 18.4 on Ubuntu 18.04
How to install Timeshift 18.4 on Ubuntu 18.04
Jul 6, 2018

Related Forums in How to create a word replacing Bash script on Ubuntu 21.04

Related Forums in How to create a word replacing Bash script on Ubuntu 21.04

Ubuntu
matthew class=
Failed to enable unit: Refusing to operate on linked unit file sshd.service
Apr 15, 2019
Ubuntu
mason class=
Passwd: You may not view or modify password information for root On Ubuntu 19.04
May 27, 2019
Ubuntu
isaac class=
/etc/apt/sources.list Permission denied
May 18, 2017
Ubuntu
yousuf class=
lsb_release command not working : Debian
Jan 18, 2018
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Ubuntu
mason class=
"E: Package 'php-mcrypt' has no installation candidate" error on Ubuntu 20.4.1
Mar 15, 2021
NFS
luke class=
clnt_create: RPC: Program not registered
Apr 25, 2017
Apache
isaac class=
How to disable apache welcome page on Ubuntu
Dec 15, 2018

Related News in How to create a word replacing Bash script on Ubuntu 21.04

Related News in How to create a word replacing Bash script on Ubuntu 21.04

How To Install Mixxx on Ubuntu 16.04
How To Install Mixxx on Ubuntu 16.04
Oct 11, 2017
Ubuntu 17.04 released with greater expectations
Ubuntu 17.04 released with greater expectations
Apr 15, 2017
Ubuntu Core now available on i.MX6 based TS-4900 thanks to Technologic Systems Inc.
Ubuntu Core now available on i.MX6 based TS-4900 thanks to Technologic Systems Inc.
Mar 1, 2017
Ubuntu 17.10 Artful Aardvark Beta 1 is now here. Download Now
Ubuntu 17.10 Artful Aardvark Beta 1 is now here. Download Now
Sep 2, 2017
Ubuntu Unity is no more: One Linux dream has been axed
Ubuntu Unity is no more: One Linux dream has been axed
Apr 7, 2017
What’s next for Ubuntu Linux Desktop?
What’s next for Ubuntu Linux Desktop?
Apr 11, 2017
Say Hi to Ubuntu's new mascot
Say Hi to Ubuntu's new mascot
Mar 22, 2019
KDE Connect App was removed from Google Play Store and brought back in 24 hours
KDE Connect App was removed from Google Play Store and brought back in 24 hours
Mar 22, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Luk Van De Looverbosch ?
How to create a root ?

Hello,
How to create root@linuxhelp in Linux Mint 20.1 64-bit ?
Thanks in advance for your reply.
Best regards.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.