Remove Blank Line from File

Remove Blank Line from File

Below are the ways to remove blank lines from file in Linux

1. Using the grep command :

grep -v "^$" file.txt

2. Using the sed command :

sed '/^$/d' file.txt

3. Using the awk command :

awk '/./' file.txt

4. Using the tr command :

tr -s '\n' < file.txt

No comments:

Post a Comment