REMOVE BLANK SPACE IN A FILE IN LINUX

If you want to remove blank space in a file , you can use these commands to make them invisible. In bash shell , blank space is denoted with the caret with dollar symbol ‘^$’

Use sed command to remove only blank space using ‘d’ option

Use grep with ‘^$’ option

Commands used

[oracle@orcl19x ~]$ cat dbsize

  INP_BYTE   OUT_BYTE OBJECT_TYPE      PCTDONE  TOTALDATA IO_THROUGHPUT
---------- ---------- ------------- ---------- ---------- -------------
         0          0                        0       5364    13
671.992188 671.992188 DB FULL       12.5278186       5364    13.9266707

[oracle@orcl19x ~]$ sed '/^$/d' dbsize
  INP_BYTE   OUT_BYTE OBJECT_TYPE      PCTDONE  TOTALDATA IO_THROUGHPUT
---------- ---------- ------------- ---------- ---------- -------------
         0          0                        0       5364    13
671.992188 671.992188 DB FULL       12.5278186       5364    13.9266707

[oracle@orcl19x ~]$ cat dbsize|grep -v '^$'
  INP_BYTE   OUT_BYTE OBJECT_TYPE      PCTDONE  TOTALDATA IO_THROUGHPUT
---------- ---------- ------------- ---------- ---------- -------------
         0          0                        0       5364    13
671.992188 671.992188 DB FULL       12.5278186       5364    13.9266707

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s