shell pipe "loses" parts of the data, was: help needed to debug Perl script

Ralf Mardorf silver.bullet at zoho.com
Wed Oct 17 17:05:23 UTC 2018


On Wed, 17 Oct 2018 18:36:18 +0200, M. Fioretti wrote:
>b) AND the data also contained, for the first time, non-ascii
>characters that make grep fail unless the -a option is used
>
>I am not sure at all of what I have just written, and every comment,
>and tip to make sure this does not happen again in some future script
>is very welcome.

Hi,

even 'grep -a' could return undesired output. A way to workaround this
issue might be using the 'strings' command and than piping through
'grep'.

[rocketmouse at archlinux ~]$ grep -a SOURCE /var/log/journal/a243f4e05c294b13ab6972bf4ff93907/system.journal | tail -1
_SOURCE_REALTIME_TIMESTAMP=1539795805565362��R��q�ox!�b���_��I���t'��޿�v�|����8�&�������8���G��H�8�Qk��|���?
[rocketmouse at archlinux ~]$ strings /var/log/journal/a243f4e05c294b13ab6972bf4ff93907/system.journal | grep SOURCE | tail -1
_SOURCE_REALTIME_TIMESTAMP=1539795805565362
[rocketmouse at archlinux ~]$

Regards,
Ralf





More information about the ubuntu-users mailing list