Guest User

Untitled

a guest
Jan 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. $ iconv -f UTF-16LE -t UTF-8 myfile.txt | grep pattern
  2.  
  3. #! /usr/bin/env perl
  4. use strict;
  5. use warnings;
  6. die "3 args are required" if scalar @ARGV != 3;
  7. my $if =$ARGV[0];
  8. my $of =$ARGV[1];
  9. my $pat=$ARGV[2];
  10. open(my $ifh, '<:encoding(UTF-16LE)', $if) or warn "Can't open $if: $!";
  11. open(my $ofh, '>:encoding(UTF-16LE)', $of) or warn "Can't open $of: $!";
  12. while (<$ifh>) { print $ofh $_ if /^$pat/; }
  13.  
  14. rg pattern filename
Add Comment
Please, Sign In to add comment