Languages
[Edit]
EN

Bash - remove new line characters from file with tr command

9 points
Created by:
Theodora-Battle
338

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

 

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