• 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 Debian 11.3

  • 00:36 lsb_release -a
  • 00:47 sudo -s
  • 00:54 cd
  • 01:04 nano test.sh
  • 04:00 sh test.sh
  • 04:32 nano file.txt
{{postValue.id}}

To save user inputs in a file with Bash Script on Debian 11.3

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 below Command

linuxhelp@linuxhelp:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye

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

lnuxhelp@linuxhelp:~$ sudo -s

Step 3: Change to home directory by using the below Command

root@linuxhelp:/home/linuxhelp# cd

Step 4: Create the Bash Script file by using the below command

root@linuxhelp:~# nano 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 below command

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

Step 6: View the saved file by using the below command

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

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to Save user inputs in a file with Bash Script on Debian 11.3. Your feedback is much welcome.

Tags:
connor
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What are Bash scripts used for?

A

Bash scripting is a useful tool for a developer to utilize in increasing productivity and managing menial, repetitive tasks. A script, with proper set permissions and syntax, can execute commands in a fraction of the time a user would take.

Q

What are the advantages of using bash scripts?

A

There are several advantages to using bash scripts and only a few disadvantages.
Advantages of Bash Scripts
Simple to create.
Can run multiple commands easily.
Interactive debugging.
Portable.
Time-saving.
Cost-effective.
Can be automated.

Q

Is bash a scripting language?

A

Bash is a powerful programming language, one perfectly designed for use on the command line and in shell scripts. This three-part series explores using Bash as a command-line interface (CLI) programming language.

Q

What is bin bash?

A

/bin/bash is the most common shell used as the default shell for user login of the Linux system. The shell's name is an acronym for Bourne-again shell. Bash can execute the vast majority of scripts and thus is widely used because it has more features, is well-developed, and has better syntax.

Q

What is the first line of a bash script?

A

The bash first line in the script begins with a shebang (#!). These are two mandatory characters, after which is indicated which program you are using for scripting. Now it is bin/bash, but other programs use this mechanism. If you did not specify the program, bash will be used by default.

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 Jayce ?
What are the types of table used in IPtables

What are the various types of table used in IPtables and how to use that for my server security?

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.