31 件 見つかりました。
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use open ':utf8';
binmode STDIN, ":utf8";
binmode STDOUT, ":utf8";
my $cps_str = ""; # character positions
GetOptions("c=s" => \$cps_str);
my @cps = sort {_toint($a) <=> _toint($b)} split(/,/, $cps_str);
sub _toint {$_[0] =~ /^(\d+)/; $1}
while (<>) {
chomp;
my @c = split(//, $_);
foreach my $cp (@cps) {
if ($cp =~ /^(\d+)-(\d+)$/) {
print map {defined $_ ? $_ : ""} @c[($1-1)..($2-1)];
} else {
print $c[$cp-1]||"";
}
}
print "\n";
}
echo "あいうえおかきくけこ" | cut8 -c 1-3,7-9 あいうきくけ
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use open ':utf8';
binmode STDIN, ":utf8";
binmode STDOUT, ":utf8";
my $width = 80;
GetOptions("width=s" => \$width);
while (<>) {
chomp;
my $line = $_;
if (length($line)) {
while ($line =~ s/^(.{$width})//) {
print "$1\n";
}
next if not length($line);
}
print "$line\n";
}
echo "あいうえおかきくけこ" | fold8 -w 4 あいうえ おかきく けこ