Você pode usar colrm
de util-linux
colrm 59 < file
Eu tenho este exemplo de um arquivo de log que está me deixando louco. Eu quero remover os últimos 8 dígitos, mas o problema há dois pontos em diferentes lugares, então eu tentei awk, mas não funcionou. este é o conteúdo do arquivo:
L258A:lp=L258:sd=LXXXK.S11:qt=text:00001000,mgfgfhghjk:09809898785
L258B:lp=L258:sd=LXXXK.S11:qt=raw:00002000lkjhgfdgfhghjk:098767894
L629A:lp=L629:sd=LXXXK.S11:qt=text:00003000oiuytyuiup:987656788903
L629B:lp=L629:sd=LXXXK.S11:qt=raw:00004000kljhkl;lkjhlk:0987656797
D206:rm=WXXBQ9Q2:rp=P11111PLD19L206DRAFT$:qt=auto:qg=107:000050009
D208:rm=WXXBQ9Q2:rp=P11111PLD19L208DRAFT$:qt=auto:qg=107:000060003
D210:rm=WXXBQ9Q2:rp=P11111PLD19L210DRAFT$:qt=auto:qg=107:000070005
D254:rm=NXXQ9QG:rp=P11111PLD19L254DRAFT$:qt=auto:qg=143:0000800047
D255:rm=NXXQ9QG:rp=P11111PLD19L255DRAFT$:qt=auto:qg=143:0000900049
D257:rm=NXXXQQG:rp=P11111PLD19L257DRAFT$:qt=auto:qg=143:0001100044
C783:rm=WXSBQ9QF:rp=P11111PLD19L783$:qt=auto:qg=139:00065000465783
C545:rm=WXSBQ9Q6:rp=P11111PLD19L545$:qt=auto:qg=133:00066000346635
C546:rm=WXSBQ9Q6:rp=P11111PLD19L546$:qt=auto:qg=133:00067000343438
C547:rm=WXSBQ9Q6:rp=P11111PLD19L547$:qt=addd:qg=133:00068000345549
C548:rm=WXSBQ9Q6:rp=P11111PLD19L548$:qt=asss:qg=133:00069000565449
C256:rm=WXSBTQ75:rp=P11111PLD19L256$:qt=auto:qg=208:jkk:0987678787
P221A:lp=P221:sd=L003K.111:qt=text:00071000asdkjasdue8:87656787906
P221B:lp=P221:sd=L003K.111:qt=raw:00072000dsfdghdfsafgg:3245667855
P301A:lp=P301:sd=L003K.111:qt=text:00073000kjhgcbvbmnlo:9098765563
P301B:lp=P301:sd=L003K.111:qt=raw:00074000poiuhgtyreewr:9876545673
TRRR:rm=AUxxxbM:rp=TRMS:cl=|writer=%f|jobn=%j:qt=cctl:000750005673
A saída obrigatória como este texto:
L258A:lp=L258:sd=LXXXK.S11:qt=text:00001000,mgfgfhghjk:098
L258B:lp=L258:sd=LXXXK.S11:qt=raw:00002000lkjhgfdgfhghjk:0
L629A:lp=L629:sd=LXXXK.S11:qt=text:00003000oiuytyuiup:9876
L629B:lp=L629:sd=LXXXK.S11:qt=raw:00004000kljhkl;lkjhlk:09
D206:rm=WXXBQ9Q2:rp=P11111PLD19L206DRAFT$:qt=auto:qg=107:0
D208:rm=WXXBQ9Q2:rp=P11111PLD19L208DRAFT$:qt=auto:qg=107:0
D210:rm=WXXBQ9Q2:rp=P11111PLD19L210DRAFT$:qt=auto:qg=107:0
D254:rm=NXXQ9QG:rp=P11111PLD19L254DRAFT$:qt=auto:qg=143:00
D255:rm=NXXQ9QG:rp=P11111PLD19L255DRAFT$:qt=auto:qg=143:00
D257:rm=NXXXQQG:rp=P11111PLD19L257DRAFT$:qt=auto:qg=143:00
C783:rm=WXSBQ9QF:rp=P11111PLD19L783$:qt=auto:qg=139:000650
C545:rm=WXSBQ9Q6:rp=P11111PLD19L545$:qt=auto:qg=133:000660
C546:rm=WXSBQ9Q6:rp=P11111PLD19L546$:qt=auto:qg=133:000670
C547:rm=WXSBQ9Q6:rp=P11111PLD19L547$:qt=addd:qg=133:000680
C548:rm=WXSBQ9Q6:rp=P11111PLD19L548$:qt=asss:qg=133:000690
C256:rm=WXSBTQ75:rp=P11111PLD19L256$:qt=auto:qg=208:jkk:09
P221A:lp=P221:sd=L003K.111:qt=text:00071000asdkjasdue8:876
P221B:lp=P221:sd=L003K.111:qt=raw:00072000dsfdghdfsafgg:32
P301A:lp=P301:sd=L003K.111:qt=text:00073000kjhgcbvbmnlo:90
P301B:lp=P301:sd=L003K.111:qt=raw:00074000poiuhgtyreewr:98
TRRR:rm=AUxxxbM:rp=TRMS:cl=|writer=%f|jobn=%j:qt=cctl:0007
Você pode usar colrm
de util-linux
colrm 59 < file
Tags text-processing