Uma solução fácil seria usar o )
como o separador de campo para awk
. Isso contorna os dois problemas que você mencionou. No entanto, isso também remove o )
de cada linha, portanto, é necessário adicioná-los novamente quando você chamar printf
:
$ awk -F')' '{printf "%-55s %-15s %-20s %-35s %-15s %-15s %-15s \n",
$1")",$2")",$3")",$4")",$5")",$6")",$7")"}' temp.txt
QUEUE(XYZ1.REQ.YAM.ALIAS) TYPE(QCLUSTER) CLUSTER(MYCLUS) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ4.REPL.YAM) TYPE(QCLUSTER) CLUSTER(MYSTER) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ8.REQ.YAM) TYPE(QCLUSTER) CLUSTER(MYCTER) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(NO) PUT(DISABLED)
QUEUE(XYZ8.REPLY.YAM) TYPE(QCLUSTER) CLUSTER( ) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(KK.RAMAN.K.LQ) TYPE(QCLUSTER) CLUSTER(MYCLUSTER) CLUSQMGR() CLUSQT(QLOCAL) DEFPSIST(NO) PUT(ENABLED)
QUEUE(KK.RAMAN.KATHPALIA) TYPE(QREMOTE) CLUSTER(MYCLUSTER) CLUSQMGR(ABCD) CLUSQT(QLOCAL) DEFPSIST(NO) PUT(ENABLED)
QUEUE(KATHPLAIA.RAMAN) TYPE( ) CLUSTER( ) CLUSQMGR(ABCD) CLUSQT(QLOCAL) DEFPSIST(NO) PUT(ENABLED)
QUEUE(XYZ8.REQ.EQUAL.LQ) TYPE(QCLUSTER) CLUSTER(MYCLUSTER) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QLOCAL) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ9.RAMAN.EQUAL.LQ) TYPE(QL) CLUSTER(MYCLUSTER) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XX10.REPL.EQUAL.ALIAS) TYPE(QA) CLUSTER(YOURC) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(DISABLED)
QUEUE(XX10.KATHPLAIA.EQUAL.LOCAL) TYPE(LOCALQ) CLUSTER(MYCLUSTER) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XX11.RAMAN.EQUAL.LOCAL) TYPE(QCLUSTER) CLUSTER(MYCLUS) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XX11.REQ.LOCAL) TYPE(QCLUSTER) CLUSTER(MYCLUSTER) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(RAMAN_KATHPLIA_000_11.REQ.EQUAL.REMOTE.QUEUE) TYPE(QCLUSTER) CLUSTER(MYCLUS) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(DISABLED)
QUEUE(XYZ2.REQ.RAMAN.REMOTE.QUEUE) TYPE(QLOCAL) CLUSTER(STER) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ2.REQ.EQUAL.REMOTE.QUEUE) TYPE(QCLUSTER) CLUSTER( ) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
Eu não entendo porque você tem esses espaços extras. Por que não algo assim:
$ awk -F')' '{printf "%-51s%-15s%-20s%-28s%-15s%-15s%-15s\n",
$1")",$2")",$3")",$4")",$5")",$6")",$7")"}' temp.txt
QUEUE(XYZ1.REQ.YAM.ALIAS) TYPE(QCLUSTER) CLUSTER(MYCLUS) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ4.REPL.YAM) TYPE(QCLUSTER) CLUSTER(MYSTER) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ8.REQ.YAM) TYPE(QCLUSTER) CLUSTER(MYCTER) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(NO) PUT(DISABLED)
QUEUE(XYZ8.REPLY.YAM) TYPE(QCLUSTER) CLUSTER( ) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(KK.RAMAN.K.LQ) TYPE(QCLUSTER) CLUSTER(MYCLUSTER) CLUSQMGR() CLUSQT(QLOCAL) DEFPSIST(NO) PUT(ENABLED)
QUEUE(KK.RAMAN.KATHPALIA) TYPE(QREMOTE) CLUSTER(MYCLUSTER) CLUSQMGR(ABCD) CLUSQT(QLOCAL) DEFPSIST(NO) PUT(ENABLED)
QUEUE(KATHPLAIA.RAMAN) TYPE( ) CLUSTER( ) CLUSQMGR(ABCD) CLUSQT(QLOCAL) DEFPSIST(NO) PUT(ENABLED)
QUEUE(XYZ8.REQ.EQUAL.LQ) TYPE(QCLUSTER) CLUSTER(MYCLUSTER) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QLOCAL) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ9.RAMAN.EQUAL.LQ) TYPE(QL) CLUSTER(MYCLUSTER) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XX10.REPL.EQUAL.ALIAS) TYPE(QA) CLUSTER(YOURC) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(DISABLED)
QUEUE(XX10.KATHPLAIA.EQUAL.LOCAL) TYPE(LOCALQ) CLUSTER(MYCLUSTER) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XX11.RAMAN.EQUAL.LOCAL) TYPE(QCLUSTER) CLUSTER(MYCLUS) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XX11.REQ.LOCAL) TYPE(QCLUSTER) CLUSTER(MYCLUSTER) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(RAMAN_KATHPLIA_000_11.REQ.EQUAL.REMOTE.QUEUE) TYPE(QCLUSTER) CLUSTER(MYCLUS) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(DISABLED)
QUEUE(XYZ2.REQ.RAMAN.REMOTE.QUEUE) TYPE(QLOCAL) CLUSTER(STER) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ2.REQ.EQUAL.REMOTE.QUEUE) TYPE(QCLUSTER) CLUSTER( ) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
Outra abordagem é converter todos os espaços seguindo um )
para guias e usar guias como o separador de campo:
$ sed 's/) */)\t/g' temp.txt |
awk -F'\t' '{printf "%-52s%-15s%-20s%-28s%-15s%-15s%-15s\n",
$1,$2,$3,$4,$5,$6,$7}'
QUEUE(XYZ1.REQ.YAM.ALIAS) TYPE(QCLUSTER) CLUSTER(MYCLUS) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ4.REPL.YAM) TYPE(QCLUSTER) CLUSTER(MYSTER) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ8.REQ.YAM) TYPE(QCLUSTER) CLUSTER(MYCTER) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(NO) PUT(DISABLED)
QUEUE(XYZ8.REPLY.YAM) TYPE(QCLUSTER) CLUSTER( ) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(KK.RAMAN.K.LQ) TYPE(QCLUSTER) CLUSTER(MYCLUSTER) CLUSQMGR() CLUSQT(QLOCAL) DEFPSIST(NO) PUT(ENABLED)
QUEUE(KK.RAMAN.KATHPALIA) TYPE(QREMOTE) CLUSTER(MYCLUSTER) CLUSQMGR(ABCD) CLUSQT(QLOCAL) DEFPSIST(NO) PUT(ENABLED)
QUEUE(KATHPLAIA.RAMAN) TYPE( ) CLUSTER( ) CLUSQMGR(ABCD) CLUSQT(QLOCAL) DEFPSIST(NO) PUT(ENABLED)
QUEUE(XYZ8.REQ.EQUAL.LQ) TYPE(QCLUSTER) CLUSTER(MYCLUSTER) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QLOCAL) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ9.RAMAN.EQUAL.LQ) TYPE(QL) CLUSTER(MYCLUSTER) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XX10.REPL.EQUAL.ALIAS) TYPE(QA) CLUSTER(YOURC) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(DISABLED)
QUEUE(XX10.KATHPLAIA.EQUAL.LOCAL) TYPE(LOCALQ) CLUSTER(MYCLUSTER) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XX11.RAMAN.EQUAL.LOCAL) TYPE(QCLUSTER) CLUSTER(MYCLUS) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XX11.REQ.LOCAL) TYPE(QCLUSTER) CLUSTER(MYCLUSTER) CLUSQMGR(ABCD) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(RAMAN_KATHPLIA_000_11.REQ.EQUAL.REMOTE.QUEUE) TYPE(QCLUSTER) CLUSTER(MYCLUS) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(DISABLED)
QUEUE(XYZ2.REQ.RAMAN.REMOTE.QUEUE) TYPE(QLOCAL) CLUSTER(STER) CLUSQMGR(BLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)
QUEUE(XYZ2.REQ.EQUAL.REMOTE.QUEUE) TYPE(QCLUSTER) CLUSTER( ) CLUSQMGR(BLAHBLAHBLAHBLAH) CLUSQT(QALIAS) DEFPSIST(YES) PUT(ENABLED)