¡Te damos la bienvenida al nuevo sysarmy --help! Para recuperar tu usuario pedí un password reset.

Problema con un cat a un archivo abierto

Tengo un archivo de log de postgres, que esta siendo escrito en este momento, cuando tiro un cat me da error al llegar al final:

ERROR: se encontró un retorno de carro literal en los datos
HINT: Use «\r» para representar el retorno de carro.
CONTEXT: COPY daf_files, línea 44985

El comando bash:
find /home/bases_postgres/data96 -type f -mmin -59 -iname *.log | xargs cat -n | while read x; do echo "$x";done

El comando en postgres:
COPY files FROM PROGRAM 'find /home/bases_postgres/data96 -type f -mmin -59 -iname *.log | xargs cat -n | while read x; do echo "$x";done' WITH (FORMAT 'text') ;

El log del postgres con el error, siendo el mismo archivo el que quiero leer:

44985 2018-05-29 12:34:50.492 -03 192.168.xxx.xxx(50332) db postgres 1 idle LOG: sentencia:
44986 COPY files FROM PROGRAM 'find /home/bases_postgres/data96 -type f -mmin -59 -iname *.log | xargs cat | while read x; do echo "$x";done' WITH (FORMAT 'text') ;
44987 2018-05-29 12:34:54.494 -03 192.168.xxx.xxx(50332) db postgres 2 COPY ERROR: se encontró un retorno de carro literal en los datos
44988 2018-05-29 12:34:54.494 -03 192.168.xxx.xxx(50332) db postgres 3 COPY HINT: Use «\r» para representar el retorno de carro.
44989 2018-05-29 12:34:54.494 -03 192.168.xxx.xxx(50332) db postgres 4 COPY CONTEXTO: COPY files, línea 44985
44990 2018-05-29 12:34:54.494 -03 192.168.xxx.xxx(50332) db postgres 5 COPY SENTENCIA:
44991 COPY files FROM PROGRAM 'find /home/bases_postgres/data96 -type f -mmin -59 -iname *.log | xargs cat | while read x; do echo "$x";done' WITH (FORMAT 'text') ;

¿Me podran dar una mano?

Respuestas

  • La importancia de leer el man. agregando el -e al cat se resolvio.

    COPY daf_files FROM PROGRAM 'find /home/bases_postgres/data96 -type f -mmin -59 -iname *.log | xargs cat -e | while read x; do echo "$x";done' WITH (FORMAT 'text') ;
Este hilo ha sido cerrado.