[olug] bash help (awk/sed)

Jay Hannah jay at jays.net
Sat Jun 19 03:08:51 UTC 2004


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



More information about the OLUG mailing list