[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Re: [olug] bash help (awk/sed)




On Jun 18, 2004, at 12:54 PM, Sam Tetherow wrote:
We don't need to, it is pretty self evident that if you wanted to do this project the easy way it would have been done in perl.

And most of us being the purist hackers that we are would not want to interfer with someone who is obviously trying to accomplish a task in a convoluted manner for the pure joy of having accomplished something trivial in a difficult manner using nothing but the virtual equivalent of duct-tape and a pen-knife.

:)

LOL

Wait a minute... are you saying Perl doesn't make good duct tape, nor a good pen-knife?! Blasphemer! Damn I'm a fickle jealot...

I hacked out the obvious solution to the problem. In Perl, of course. Here you go:


                                      ''=~('('.'?'
           .'{'.(                   '`'|'%').("\["^
        '-').('`'|                '!').('`'|',').'"'
 .('!'^'+')  .('['^              '+').('['^')').('`'|
')').('`'|'.').('['^            '/').('{'^'[').('\\').
'"'.'\\'.'\\'.(('`')|          '.').('`'^'/').('`'|'-'
  ).('`'|'!').(('`')|        '(').('`'|'!').('{'^'[').(
       '`'^',').('`'|      ')').('`'|'.').('['^'.').('['
      ^'#').('{'^'['     ).('{'^'.').('['^'(').('`'|'%').
     ('['^')').('['^   '(').('{'^'[').('`'^"'").('['^')').
    ('`'|'/').('['^   '.').('['^'+').('{'^'[').('{'^(')')).(
    '['^'.').("\`"|  ',').('`'|'%').('['^'(').'!'.'\\'.'\\'.(
    '`'|'.').'\\'.  '\\'.('`'|'.').'\\'.'"'.';'.('!'^('+')).(
    '['^'+').('['^  ')').('`'|')').('`'|'.').('['^'/').(('{')^
    '[').'\\'.'"'.('`'^'.').('`'|'/').('['^'/').('{'^'[').('`'
    |'!').('['^'(').('{'^'[').('`'|'#').('`'|'/').('`'|('/')).(
     '`'|',').('{'^'[').('`'|'!').('['^'(').('{'^'[').('['^'/')
     .('`'|'(').('`'|'%').('{'^'[').('`'^'/').('`'|'-').('`'|'!'
      ).('`'|'(').('`'|'!').('{'^'[').('{'^'+').('`'|'%').(('[')^
       ')').('`'|',').('{'^'[').('`'^'-').('`'|'/').('`'|('.')).(
        '`'|"'").('`'|'%').('['^')').('['^'(').','.('{'^'['). (((
         '`'))|'"').('['^'.').('['^'/').('{'^'[').('`'|'(').  (((
          '`'))|'%').('['^'"').('{'^'[').'-'.('-'). '\\'.''.  (((
            '\\'))).('`'|'.').'\\'.'\\'.('`'|'.').  ('\\').   '"'
             .';'. ('!'^'+').('['^'+').('['^')').   (('`')|   ')'
                   ).('`'|'.').('['^'/').(('{')^    ('[')).   (((
                   '\\'))).    '"'.("\{"^ '[').(     ('{')^   ((
                   '['))).     ('{'^'['   ).('['     ^'/').  +(
                   '`'|'('     ).("\`"|   '%').       ('['^  (
                   '"')).      ('{'^'['   ).+(         '['^
                   '/').(     '['^')').   ('['         ^'"'
                    ).'!'     .('\\').    '\\'         .''.
                    ('`'|     ('.')).     '\\'         .''.
                    '\\'     .('`'|       '.')         .''.
                    '\\'     .((          '"')         ).((
                    ';')      ).(         '!'          ^((
                    '+'        )))       .+(           '!'
                    ^((         '+'     )))            .((
                    '"'          )).   '}'              .+
                    ((             ')')))               ;(
                    $:              )='.'               ^+
                    ((             '~'));$~             =(
                   '@'            )|(( '('))            ;(
                  $^)           ="\)"^  '[';           $/=
                 '`'|         "\.";$,=   '('          ^'}'
               ;($\)=                                ('`')|
             "\!";$:=                               ')'^'}'


Yes, seriously. Paste that into olug.pl or whatever and "perl olug.pl". You'll be amused. Maybe. In any event, I was amused and everyone will agree that that is what's important. -grin-

j
Omaha Perl Mongers: http://omaha.pm.org

P.S. Mike cheated. He used ls in his "awk for everything" solution. Boo.

Certified 100% Perl:
opendir(D, ".");
foreach $f (readdir D) {
   open (I, $f);
   while (<I>) {
      /^(\d{6}-\w)/ && print "$1,$f\n";
   }
}




troehr@nj-onramp.com wrote:
Now we're just waiting for the Perl Mongers to chime in... ;^)
Later,
Tom
Quoting Mike Hostetler <hostetlerm@gmail.com>:
On Fri, 18 Jun 2004 10:45:01 -0500, troehr@nj-onramp.com
<troehr@nj-onramp.com> wrote:

Or to avoid awk,

Or use awk for everything:

for f in `ls -1 *.txt`; do
 awk --assign infile=$f '/[0-9]+?-[A-F]/ {print $0 "," infile}' $f
done


-- mikeh