Linux Reader 4.0Ext 2/3/4, UFS2, HFS and ReiserFS/4 for Windows
Linux Reader 4.0
Ext 2/3/4, UFS2, HFS and ReiserFS/4 for Windows

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:

The script above will print

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

Here’s another way to do this:

This will print:

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.

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:

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 Ext4 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.

Launch the app to view all the Linux partitions files.

Choose the partition where you saved the Linux files.

View all the Linux files; Linux Reader can read media files, documents, and any other files. 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.

FREE DOWNLOADVer 4.0, Win Upgrade to PROFrom $29.95

0.20030307769775