perl scriptname file1 file2 file3... #### #!/usr/bin/perl use warnings; use strict; my @search = qw( group1 group2 group11 ); my $regex = join '|', sort { length $b <=> length $a } @search; $regex = qr/($regex)/; while (<>) { if (my ($found) = /$regex/) { print STDERR "Moving $ARGV into $found\n"; -d $found or mkdir $found or die $!; rename $ARGV, "$found/$ARGV" or die $!; } } #### choroba@still ~ $ echo group1 > a choroba@still ~ $ echo group2 > b choroba@still ~ $ echo group11 > c choroba@still ~ $ perl 1223194.pl a b c Moving a into group1 Moving b into group2 Moving c into group11 choroba@still ~ $ ls a b c ls: cannot access 'a': No such file or directory ls: cannot access 'b': No such file or directory ls: cannot access 'c': No such file or directory ([2]) choroba@still ~ $ find group* -type f group1/a group11/c group2/b #### ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,