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

How to save user inputs in a file with Bash Script on Ubuntu 21.04

  • 00:36 lsb_release -a
  • 00:46 sudo -s
  • 00:55 cd ~
  • 01:03 vi test.sh
  • 05:59 sh test.sh
  • 06:32 vi file.txt
6757

To Save user inputs in a file with Bash Script on Ubuntu 21.04

Introduction:

Bash scripts are computer programs that are run by the Unix shell, a command-line interpreter. They consist of a plain text file containing a series of commands. Shell scripts typically manipulate files, execute programs, and print text.

Step 1: Check the OS version by Using the Following Command

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

Step 2: Login as root user by using the following command

lnuxhelp@linuxhelp:~$ sudo -s

Step 3:Changing to home directory by using Following Command

root@linuxhelp:/home/linuxhelp# cd ~

Step 4:Create the Bash Script file

root@linuxhelp:~# vi test.sh
#!/bin/bash

echo what is your name?
read name

echo What is your age?
read age

echo what is your qualification ?
read degree

echo where are you from ?
read place


echo Name : $name > file.txt

echo Age : $age >> file.txt

echo Qualification : $degree >> file.txt

echo Place : $place >> file.txt

Step 5:Run the Bash script by the following command

root@linuxhelp:~# sh test.sh 
what is your name?
Aravind
What is your age?
23
what is your qualification ?
BE
where are you from ?
India

Step 6: Viewing the saved file

root@linuxhelp:~# vi file.txt 
Name : Aravind
Age : 23
Qualification : BE
Place : India                   

By save user inputs in a file with Bash Script on Ubuntu 21.04 Comes to an end

Tags:
benjamin
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What does the Bash script exactly do?

A

Bash script executes the serial of commands.

Q

What is $? In bash script?

A

$? is a special variable in a shell that reads the exit status of the last command executed.

Q

From what is Bash is written in?

A

Bash is written in C language which executes commands written in C language?

Q

What is an extension of bash Script?

A

The Bash script extension is .sh

Q

What would be the first line of any Bash Script?

A

The first line of any Bash Script would be "#!/bin/bash" which calls the bash program.

Related Tutorials in How to save user inputs in a file with Bash Script on Ubuntu 21.04

Related Tutorials in How to save user inputs in a file with 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 save user inputs in a file with Bash Script on Ubuntu 21.04

Related Forums in How to save user inputs in a file with 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 save user inputs in a file with Bash Script on Ubuntu 21.04

Related News in How to save user inputs in a file with 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 Gibbson ?
How do i run both nginx and apache in same instance on centos

Hi...,

my server is based centos operating system and my webserver is already running on Apache.... i need to run both apache and nginx on same instance ... please help me to implement this concept...

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.