develooper Front page | perl.perl6.users | Postings from August 2018

tip: grep and sed stopped working

From:
Todd Chester
Date:
August 17, 2018 07:27
Subject:
tip: grep and sed stopped working
Message ID:
e052c75e-c6a1-00e3-72db-7472471dada9@zoho.com
Hi All,

I had the unfortunate experience of grep and sed
stopping working in Fedora 28.  I have to patch
a bunch of scripts.   It was a disaster.

Anyway, in case my workarounds are of interest to you
guys:

Hope this doesn't happen to you guys!
-T


uname -r
4.17.9-200.fc28.x86_64

# rpm -qa grep
grep-3.1-5.fc28.x86_64

# rpm -qa sed
sed-4.5-1.fc28.x86_64



$ echo "a-b-c" | sed -e 's/-//g'
<nothing>

Workaround:
     $ echo "a-b-c" | perl -pe 's/-//g'
     abc

     $ echo "a-b-c" | perl6 -pe 's:g/\-//'
     abc



$ ls -al /tmp | sed -n 3,4p
<nothing>

Workaround:
     $ ls -al /tmp  | perl6 -ne ".say if 3 <= ++$ <= 4"
     dr-xr-xr-x. 19 root root    278 Apr 11 20:43 ..
     drwxr--r--.  2 todd users    40 Aug 17 00:08 ARI

     $ x=3; y=4; ls -al /tmp  | perl6 -ne ".say if $x <= ++$ <= $y"
     dr-xr-xr-x. 19 root root    278 Apr 11 20:43 ..
     drwxr--r--.  2 todd users    40 Aug 17 00:08 ARI



# echo "abc" | grep  "ab"
<nothing>

Work around ("ack" is a Perl 5 program):
     $ echo "abc" | ack "ab"
     abc



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About