Linux Reader
Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows

Pew Pew madafakas!

Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows
Last updated: Jul 29, 2021

How to Get a New Line in Shell Script

Newline is used to identify the end of a line in a script to mark the beginning of a new line, referred to as line break or line feed. Just as you will put the br tag in HTML scripts to force the subsequent characters into a new line, that’s what newline means in shell scripts.

Here you will find out:

  • how to skip from one line to another
  • different methods of how to use a new line
  • when DiskInternals can help you

Are you ready? Let's read!

The simplest way to use a new line in a shell script

There are quite a couple of ways to insert a new line in a shell script. However, here are some of the simplest methods to do this:

Example 1 - new line with echo command

The script above will print

Example 2 - new line

When you write the “echo” command without attaching any argument, it prints a blank line.

Here’s another way to do this:

Example 3 - new line

This will print:

Example 4 - new line

The most used newline character

If you don’t want to use echo repeatedly to create new lines in your shell script, then you can use the \n character. The \n is a newline character for Unix-based systems; it helps to push the commands that come after it onto a new line. An example is below.

Example 5 - new line with n character

Using printf command in a shell script

It is possible to use printf in place of echo. Printf is the alternative way to insert newlines in shell scripts instead of using echo –e. This is because the -e flag isn’t compatible with all systems.

Printf is compatible with quite many systems, and it is more reliable; however, it is not in compliance with POSIX. Also, you will need to add \n at the end, because printf doesn't automatically add new lines as echo does.

For example:

Example 6 - new line

What to do to open Linux files from Windows?

Typically, you cannot open Linux files from Windows, but sometimes you may be in urgent need to access the files in your Ext2/3/4 partitions. In such scenarios, DiskInternals Linux Reader can be of great help. This software tool helps you to access Linux files from a Windows PC. It is a freeware program with an intuitive interface. Using DiskInternals Linux Reader, you can view and access Linux files, but you cannot edit them directly.

Steps to read Linux files on Windows

First, you need to install DiskInternals Linux Reader on your PC.

DiskInternals Linux Reader - the window of the installation

Launch the app to view all the Linux partitions files.

Choose the partition where you saved the Linux files.

DiskInternals Linux Reader - select the Linux disk

View all the Linux files; Linux Reader can read media files, documents, and any other files on the file systems (Ext2/3/4, ReiserFS, Reiser4, HFS, HFS+, FAT, exFAT, NTFS, ReFS). To view a file, right-click on the file and select “Preview in New Window”.

Now copy the files from the Linux partition to Windows partitions and start editing.

Related articles

FREE DOWNLOADVer 4.18, WinUpgrade to PROFrom $29.95

Please rate this article.
4.611 reviews