Languages
[Edit]
EN

Bash - remove new line characters from file with tr command

9 points
Created by:
Theodora-Battle
528

Using Bash console it is possible to remove newline characters in the following ways.

Quick solution:

tr -d '\r\n|\n\r|\n|\r' < input_file.txt > output_file.txt

 

1. CRLF removing examples

tr -d '\r\n' < input_file.txt > output_file.txt

or: 

cat input_file.txt | tr -d '\r\n' > output_file.txt

2. LF removing example

tr -d '\n' < input_file.txt > output_file.txt

or: 

cat input_file.txt | tr -d '\n' > output_file.txt

 

Alternative titles

  1. Bash - remove newline characters from file with tr command
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Bash

Bash - remove new line characters from file with tr command
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join