How to Use a Bash Multiline Command
Bash multiline commands simply refer to commands that span more than one line. In this article, you will understand more on how bash reads/handles multiline commands. Also, at the end of this article, a handy software utility is introduced. This software utility will help you to read and access Linux files on a Windows PC without any stress.
Here you will find out:
- when you can use a bash multiline command
- how to print a multiline command
- when DiskInternals can help you
Are you ready? Let's read!
Long command lines and a bash multiline command
When your script contains long command lines, bash will continue to read the commands non-stop; if the cursor gets to the right-hand end, bash continues to the next line automatically. However, if you want bash to read your script line by line, then you must introduce a backslash (\) at the end of each line. Also, bash doesn’t support multiline comments; you have to write the comments serially.
Using a backslash \ or « to print a bash multiline command
If you’re writing a multiline command for bash, then you must add a backslash (\) at the end of each line. For multiline comments, you have to use the HereDoc « tag.
Multiline comments written serially:
Multiline comments written with «:
Bash will ignore everything in here.
Comments
Note: you must repeat the command you used in the first line at the end of the comment, and it should be written in ALL CAPS.
Practical Example:
Output
Write a comment with the hash mark (#)
Using # is the simplest way to write comments in bash. It is the most common way of writing comments.
Example:
Output:
The bash multiline command with “()”
Some users have confirmed that using brackets “()” can help to tell bash that it’s about to read a multiline command.
Example:
Using this blob, let's tell bash it's a multiline command:
Using “()”
Bash will now read the next lines by attaching a ">" for each new line.
Use Linux Reader to open Linux files
As promised, here's the software to use and open Linux files on a Windows PC. DiskInternals Linux Reader is an intuitive software app with an easy-to-understand interface. It displays all the Linux partitions present on a Windows PC and lets you access the important files that are saved inside. Linux Reader works with different file systems: Ext2/3/4, ReiserFS, Reiser4, HFS, HFS+, FAT, exFAT, NTFS, ReFS, UFS2, RomFS(reader), ZFS (preview only*), XFS (preview only*), Hikvision NAS and DVR (preview only*).
Also, DiskInternals Linux Reader works perfectly for a virtual machine and dual-boot PCs. It is a handy app for all Linux operators. More interestingly, DiskInternals Linux Reader is free to download and use.Related articles
- About a bash date command
- How to Access Linux Ext2 or Ext3 on Windows
- How to Access Ext4 from Windows
- How to Mount Ext4 on Windows for Free
- Mount Linux Drive on Windows for Free
- Bash Script: All You Need to Know
- An Algorithm: How to Create Bash While Loop
- Linux Shell: What You Need to Know at First
- 5 Basic Shell Script Examples for Your First Script
- Bash: How to Check if the File Does Not Exist
- Bash Time Command on Linux
- How to use bash get script directory in Linux
- How to Check Bash String Equality
- How to Use Linux Wait Command
- Bash: How to Loop Through Files in Directory
- 20 Examples of Bash Find Command
- Bash Cat Command in Examples
- Bash Script SSH: How to Use It
- Bash: A Script For User Input
- Linux ZSH: the basic you need to know
- Basic of Grep in Linux Shell Script
- Shell Script Cut: Basic You Need to Know
- Bash: How to Check if String Not Empty in Linux
- Bash: how to split strings in Linux
- Linux: Sudo in Bash Scripts
- Hello World Script in Bash
- A Linux bin/bash Shell
- Linux: New Line in Shell Script
- Linux: Bash String Ends With
- Linux: Bash Printf Examples
- Linux: Bash First Line
- Linux: $0 in a Shell Script
- Linux: A Bash Startup Script
- Linux: Write a Shell Script
- Shell Script: Replace String in File
- A crontab service shell script
- Bash and sh: is there any difference
- A Bash Dirname Command
- Linux: A Bash Source Command
- A Bash to Loop through Lines in File
- Linux: A Bash Linter
- A Bash Nested Loop
- A Bash Test Command
- Use a Shell Script to Send an Email
- A Bash Status of Last Command
- Linux: A Bash Basename Command
- Using Bash to Write to a File
- About Bash Language
- Bash for Loop in One Line
- AWK in a Bash Script
- Learn about useful bash scripts
- Learn about systemd startup script
- About chaining bash commands
- Learn about a bash error code
- Using a bash tee command
- About a bash export command
- Learn about a bash wait command
- Arch Linux install script
- About advanced bash scripting
- To run a shell script in Dockerfile
- About a bash UNTIL loop
- Learn about C shell script
- Learn about Korn shell scripting
- Using /usr/bin/env command
- Whether bash waits for command to finish
- Using bash if 0
- Using && in an IF statement in bash
- If you want to run shell script in background
- The disk you inserted was not readable by this computer error
- Learn about SFTP in bash scripting
- Learn to run Perl script in Linux
- Examples of using the Expect
- Copy command in shell scripts
- Shell script usage
- Install Oracle Database
- Here is everything you need to know about Bash for Windows
- Guide in Pictures
- How to Use Shell Script Sleep Command




