[root@localhost ~]$ cat -n temp.txt
1 Database Administration.
2
3 Web Development.
4
5
6 IT Architecture Design.
7
8
9
10 Project Management.
11
12
13
14
There're many blank lines in the file temp.txt. Here are the methods to remove them.
- Squeeze repeated new line characters into one new line character by tr.
- Delete empty lines by sed.
- Select non-blank lines by grep or egrep.
[root@localhost ~]$ cat temp.txt | tr -s 'n'
Database Administration.
Web Development.
IT Architecture Design.
Project Management.
[root@localhost ~]$ cat temp.txt | sed '/^$/d'
Database Administration.
Web Development.
IT Architecture Design.
Project Management.
[root@localhost ~]$ grep -v '^$' temp.txt
Database Administration.
Web Development.
IT Architecture Design.
Project Management.