Languages
[Edit]
EN

Bash - remove new line characters from file with tr command

6 points
Created by:
Kate_C
2857

Using Bash console it is possible to remove new line characters in following ways.

1. CRLF removing examples

1.1. File streams redirection

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

1.2. Application streams redirection

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

2. LF removing example

1.1. File streams redirection

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

2.2. Application streams redirection

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

 

Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.