Posts

Showing posts with the label ^M Character

Changing the Default Terminal to Terminator on Ubuntu

Image
Terminator is a powerful tool for developers, allowing you to manage multiple terminal sessions in a single window. Features like splitting panes, tabs, and simultaneous input can significantly boost your productivity. Step 1: Install Terminator First, install Terminator using the apt package manager. sudo apt update sudo apt install terminator -y The -y option automatically answers 'yes' to any prompts during the installation process, streamlining the setup. Step 2: Set as the System Default Ubuntu uses a utility called update-alternatives to manage default applications. We'll use this tool to change the default terminal emulator ( x-terminal-emulator ) to Terminator. Run the Configuration Command Enter the following command in your terminal. A list of available terminals will appear. sudo update-alternatives --config x-terminal-emulator Select Terminator From the resulting list, enter the selection number corresponding to terminator and press Enter. ...

How to get rid of ^M from a text file on Linux or Unix

Image
When you transfer text files from Windows to Linux or Unix systems, you often see ' ^M' characters at the end of lines. This happens because Windows and Linux/Unix handle line breaks differently—Windows uses CR+LF ( \r\n ) , while Linux/Unix just uses LF ( \n ) . In this guide, we’ll look at a few simple ways to remove these characters and explain how each method works. $ cat -v HelloWorld.java public class HelloWorld^M {^M public static void main(String[] args) {^M System.out.println("Hello World!");^M }^M }^M Using the dos2unix command The dos2unix command is a simple and widely used method. $ dos2unix filename Using vi/vim editor In Vi/Vim, You can directly search for and remove the ' ^M' character. The command above searches for ' ^M' at the end of each line throughout the entire file and removes it. To input '^M', push Ctrl down and then press v and n consecutively. Vim on Linux: 'Ctrl + v + m' Gvim ...