[olug] bash help (awk/sed)

Eric Pierce eric_olug at yahoo.com
Sat Jun 19 05:57:36 UTC 2004


Hey, thanks everyone for laying down their ideas.

I actually went through and tried what everyone posted.  Didn't get them all to
work, but I'll go back and check them again.  There's some good learning for me
in ALL your posts.

Anyway, I know this is a simple script, but the real beauty is the
functionality of this script is turning some highly Windows-centric heads (at
my work) towards the power of Unix (Linux in this case).

The bigger picture of what I'm doing is taking a huge 2,000 page pdf, breaking
it into single files - one for each page (using 'pdftk' - Thanks Matt/Brian),
and then turning each page into plain text (xpdf's 'pdftotext') for easy
parsing with the script everyone helped me with.  This is essentially a simple
index tying parts numbers to single page pdfs for online viewing.

Thanks again!
Eric Pierce

--- Jay Hannah <jay at jays.net> wrote:
> 
> 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
> 
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


More information about the OLUG mailing list