User Tools

Site Tools


linux:bash:mengilangkan-empty-line-di-command-output

Bash: Menghilangkan Blank Output di Linux Command

Bagaimana cara menghilangkan output blank line atau empty line atau baris kosong menggunakan bash.

Contoh

Line:Text
1:<blank>
2:AAA
3:<blank>
4:BBB
5:<blank>
6:<space><space><space>CCC
7:<space><space>
8:DDD

Hasil yang ingin didapatkan adalah

1:AAA
2:BBB
3:<space><space><space>CCC
4:DDD
<code>

===== Solusi =====
Apabila ingin menghilangkan baris kosong di dalam file
<code>
sed -i '/^$/d' file.txt

Apabila ketika menampilkan via cat

cat file.txt | tr -s '\n' '\n'

Selesai dan selamat mencoba

Sumber : https://serverfault.com/questions/252921/how-to-remove-empty-blank-lines-from-a-file-in-unix-including-spaces

Layanan

Harga Domain .COM | Harga Domain .ID | Shared Hosting | Email Hosting | MySQL Hosting |
linux/bash/mengilangkan-empty-line-di-command-output.txt · Last modified: 2021/09/21 22:08 by kbadmin

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki