REMOVE BLANK SPACE IN A FILE IN LINUX

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

%d bloggers like this: