• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News 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
{{postValue.id}}

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
{{postCtrl.cmtErrMsg}}

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.

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 Luke ?
workbench for debian

I am using workbench in CentOS whereas now I need to use Debian Operating system so could you please help to install and use in Debian?

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.