The Unix "sed" command

iKnow-IT banner

The SED (stream-editor) can be very handy to manipulate output.

e.g. the output of a Unix "ls" command

-rw-r--r--1   oracle   dba   123   Mar 09 19:32 init.ora
-rw-r--r--1   oracle   dba   231   Mar 09 19:48 inittest.ora
-rw-r--r--1   oracle   dba      95  Mar 06 14:20 test.sga

can be reformatted with the following command

$ ls -l | sed 's/  */^/g'

one or more spaces / tabs are replaced by ^ sign

-rw-r--r--^1^oracle^dba^123^Mar^09^19:32^init.ora
-rw-r--r--^1^oracle^dba^231^Mar^09^19:48^inittest.ora
-rw-r--r--^1^oracle^dba^95^Mar^06^14:20^test.sga

 

 $ cat ${CANDLEHOME}/config/${PC}.ini.org |
        sed "s/^CTIRA_HOSTNAME/#CTIRA_HOSTNAME/g
             s/^CTIRA_RECONNECT_WAIT/#CTIRA_RECONNECT_WAIT/g
             s/^CTIRA_MAX_RECONNECT_TRIES/#CTIRA_MAX_RECONNECT_TRIES/g
             s/^KDC_FAMILIES/#KDC_FAMILIES/g
             s/^CTIRA_HIST_DIR/#CTIRA_HIST_DIR/g
             s/^CTIRA_SIT_PATH/#CTIRA_SIT_PATH/g" > ${CANDLEHOME}/config/${PC}.ini