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:31:34 UTC 2018


On Wed, 17 Oct 2018 19:24:28 +0200, Ralf Mardorf wrote:
>On Wed, 17 Oct 2018 19:05:23 +0200, Ralf Mardorf wrote:
>>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.    
>>
>>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 ~]$  
>
>PS:
>
>Sure, without the '-a' option 'grep' might not return any text
>contained by the file [1]. Perhaps 'strings' does filter output you
                                                   ^^^^^^

"filter" in the sense of "miss", "not provide", "not return"
------------------------------------------------------------


>want to get.
>
>Since we don't know what you actually try to achieve, we only could
>provide shots in the dark. Perhaps 'grep -a' does always the trick for
>you, while 'strings' might fail regarding your needs.
>
>[1]
>[rocketmouse at archlinux ~]$ grep
>SOURCE /var/log/journal/a243f4e05c294b13ab6972bf4ff93907/system.journal
>| tail -1 Binary
>file /var/log/journal/a243f4e05c294b13ab6972bf4ff93907/system.journal
>matches [rocketmouse at archlinux ~]$





More information about the ubuntu-users mailing list