SlideShare une entreprise Scribd logo
1  sur  9
Télécharger pour lire hors ligne
Why Perl, when you can use bash+awk+sed? :P


               Luciano Rocha



                June 6th, 2008
Introduction




    1   What’s your excuse?


    2   The hand is faster than the mind!


    3   What if...


    4   No more hunting!


    5   Vrooom!
What’s your excuse (or, Learn your tools)




    Increase productivity
    Having a profound understanding of the tools you interact with daily will
    increase your productivity immensely.

    Example: shell history

    $ wget h t t p : / / . . . / r s y s l o g −3.19.6. t a r . gz
    ...
    $ tar xf ! $ : t
    t a r x f r s y s l o g −3.19.6. t a r . gz
    $
Learn your tools, cont.



    Example: extended globs

    # rpm −Uvh . . . / RPMS/ i 3 8 6 / postgres −∗
    E r r o r : something r e q u i r e s p g s q l
    # rpm −i v h ! $ : h / p o s t r e s q l−l i b s ∗ # i n s t a l l l i b
    # rpm −Uvh ! $ : h / p o s t g r e s q l −!( t e s t ∗ | d e b u g i n f o ∗ | l i b s ∗) # upgrade t o o l s
    ...
    # # r e b u i l d dependencies



    Example: lib dependencies

    $ f i n d . −type f −perm −u+x −o −name  ∗ . so |
             xargs r e a d e l f −d 2 >/ dev / n u l l |
             sed −ne ’ /NEED/ s , . ∗  [  ( . ∗  )  ] ,  1 , p ’ |
             s o r t −u
    l i b a s o u n d . so . 2
    l i b c o m _ e r r . so . 2
    l i b c r y p t o . so . 6
    l i b c r y p t o . so . 7
     ...
Learn your tools, cont.




    Example: fix track numbers

    $ f o r f i n ∗ .mp3 ; do i d 3 v 2 −T quot; $ { f%%[ −.]∗} quot; quot; $ f quot; ; done



    Example: remove empty files

    $ f i n d . −type f −s i z e 0 −p r i n t 0 | xargs −r 0 rm −f



    Example: create archive without ‘.svn’

    $ f i n d . −name . svn −prune −o −p r i n t | c p i o −o | g z i p −9 > source . cgz
The hand is faster than the mind! (Or, Think as you type)




    Mechanize
    Entering common commands becomes mechanical, and leaves you time to
    think the solution:
        Do ‘command’ to some files:
        find .     ...   | xargs −r . . .

        fix files:
        f o r i i n . . . ; do . . ; done
What if... (or, Incremental solutions)


    Incremental solutions
    Keep trying until you arrive to the correct solution.


    Example: find largest file

    $ f i n d . −type f |
           xargs −r s t a t −c quot;%s %n quot; |
           s o r t −r n | head



    Example: usb device associated with a disk

    $ p=$ ( udevadm i n f o −−path = / sys / b l o c k / sdc −−query=path )
    $ udevadm i n f o −e | grep −B1 bus / usb / |
        while read p sys && read n dev && read dash ; do
        echo $sys $dev ; done | LANG=C s o r t |
        while read sys dev ; do
              i f echo $p | f g r e p −q −  − $sys ; then echo $dev ; break ; f i ;
        done
No more hunting! (or, Fewer dependencies)



    Standard Unix R tools
    Perl isn’t always available, or with the packages you desire:
   $ ...
   Can ’ t l o c a t e A : : B i n @INC . . .
   $ yum −y i n s t a l l ’ p e r l (A : : B ) ’
   ( wait )
    ...
   Nothing t o do
   $ cpan A : : B
   −bash : cpan : command n o t found
   $ p e r l −MCPAN −e s h e l l
   install A::B
   ( wait )
   ( t r i e s f t p , not possible i n s i d e t h i s f i r e w a l l )
   ^C
   ^C



    Easier to learn
    The documentation for those tools are tiny, compared to Perl’s.
Vrooom! (or, Low overhead)



    Small and fast utilities
    Sometimes, you’ll be restricted in space, like in an initrd, or on the time a
    script takes to execute:
    $ t i m e awk / dev / n u l l < / dev / n u l l
    0.010 s
    $ ^awk^ p e r l
    0.023 s



    Example: Xen bridge script

    n e t c o n f _ i p = quot; $ ( i p addr show dev $1 | awk −v ORS= quot; quot; ’
                                   $1 == quot; i n e t quot; | | $1 == quot; i n e t 6 quot; {
                                             p r i n t quot; i p addr add quot; $2 ;
                                              i f ( $3 == quot; brd quot; ) p r i n t quot; brd quot; $4 ;
                                             p r i n t quot; dev $dev ; quot; ;
                                   } ’) quot;

Contenu connexe

Tendances

CRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual MachineCRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual MachineGR8Conf
 
Using docker for data science - part 2
Using docker for data science - part 2Using docker for data science - part 2
Using docker for data science - part 2Calvin Giles
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous phpWim Godden
 
Using python and docker for data science
Using python and docker for data scienceUsing python and docker for data science
Using python and docker for data scienceCalvin Giles
 
Libral - a systems management API for Linux
Libral - a systems management API for LinuxLibral - a systems management API for Linux
Libral - a systems management API for Linuxlutter
 
Rush, a shell that will yield to you
Rush, a shell that will yield to youRush, a shell that will yield to you
Rush, a shell that will yield to youguestdd9d06
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHPWim Godden
 
React PHP: the NodeJS challenger
React PHP: the NodeJS challengerReact PHP: the NodeJS challenger
React PHP: the NodeJS challengervanphp
 
ASU DUG - SVN and CVS
ASU DUG - SVN and CVSASU DUG - SVN and CVS
ASU DUG - SVN and CVSJeff Beeman
 
Docker for data science
Docker for data scienceDocker for data science
Docker for data scienceCalvin Giles
 
Configuration surgery with Augeas (OggCamp 12)
Configuration surgery with Augeas (OggCamp 12)Configuration surgery with Augeas (OggCamp 12)
Configuration surgery with Augeas (OggCamp 12)Dominic Cleal
 
Hubot: a look inside our robot friend
Hubot: a look inside our robot friendHubot: a look inside our robot friend
Hubot: a look inside our robot friendajacksified
 
Contribuir a Drupal - Entorno
Contribuir a Drupal - EntornoContribuir a Drupal - Entorno
Contribuir a Drupal - EntornoKeopx
 
Goの標準的な開発の流れ
Goの標準的な開発の流れGoの標準的な開発の流れ
Goの標準的な開発の流れRyuji Iwata
 
An Introduction to PHP... and Why It's Yucky!
An Introduction to PHP... and Why It's Yucky!An Introduction to PHP... and Why It's Yucky!
An Introduction to PHP... and Why It's Yucky!Jorge Silva Jetter
 
Augeas
AugeasAugeas
Augeaslutter
 
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterCodeIgniter Conference
 

Tendances (20)

CRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual MachineCRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual Machine
 
Using docker for data science - part 2
Using docker for data science - part 2Using docker for data science - part 2
Using docker for data science - part 2
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
 
Using python and docker for data science
Using python and docker for data scienceUsing python and docker for data science
Using python and docker for data science
 
Libral - a systems management API for Linux
Libral - a systems management API for LinuxLibral - a systems management API for Linux
Libral - a systems management API for Linux
 
Rush, a shell that will yield to you
Rush, a shell that will yield to youRush, a shell that will yield to you
Rush, a shell that will yield to you
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 
React PHP: the NodeJS challenger
React PHP: the NodeJS challengerReact PHP: the NodeJS challenger
React PHP: the NodeJS challenger
 
ASU DUG - SVN and CVS
ASU DUG - SVN and CVSASU DUG - SVN and CVS
ASU DUG - SVN and CVS
 
Docker for data science
Docker for data scienceDocker for data science
Docker for data science
 
Configuration surgery with Augeas (OggCamp 12)
Configuration surgery with Augeas (OggCamp 12)Configuration surgery with Augeas (OggCamp 12)
Configuration surgery with Augeas (OggCamp 12)
 
Hubot: a look inside our robot friend
Hubot: a look inside our robot friendHubot: a look inside our robot friend
Hubot: a look inside our robot friend
 
Contribuir a Drupal - Entorno
Contribuir a Drupal - EntornoContribuir a Drupal - Entorno
Contribuir a Drupal - Entorno
 
Goの標準的な開発の流れ
Goの標準的な開発の流れGoの標準的な開発の流れ
Goの標準的な開発の流れ
 
Dtalk shell
Dtalk shellDtalk shell
Dtalk shell
 
An Introduction to PHP... and Why It's Yucky!
An Introduction to PHP... and Why It's Yucky!An Introduction to PHP... and Why It's Yucky!
An Introduction to PHP... and Why It's Yucky!
 
Augeas
AugeasAugeas
Augeas
 
Talk NullByteCon 2015
Talk NullByteCon 2015Talk NullByteCon 2015
Talk NullByteCon 2015
 
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniter
 
Free BSD次の一歩
Free BSD次の一歩Free BSD次の一歩
Free BSD次の一歩
 

En vedette

Case Study on a Global Learning Program (OnlineEduca 2008 Conference Proceedi...
Case Study on a Global Learning Program (OnlineEduca 2008 Conference Proceedi...Case Study on a Global Learning Program (OnlineEduca 2008 Conference Proceedi...
Case Study on a Global Learning Program (OnlineEduca 2008 Conference Proceedi...Martin Rehm
 
Phoenix Energy Star Bulk Purchasing Presentation
Phoenix   Energy Star Bulk Purchasing PresentationPhoenix   Energy Star Bulk Purchasing Presentation
Phoenix Energy Star Bulk Purchasing PresentationICF_HCD
 
Potentials and Limitations of Educational Datasets
Potentials and Limitations of Educational DatasetsPotentials and Limitations of Educational Datasets
Potentials and Limitations of Educational DatasetsHendrik Drachsler
 
Focus on What Matters
Focus on What MattersFocus on What Matters
Focus on What MattersJennifer Orr
 
Designit in Barcelona: an introduction to Generative Design
Designit in Barcelona: an introduction to Generative DesignDesignit in Barcelona: an introduction to Generative Design
Designit in Barcelona: an introduction to Generative DesignGuy Haviv
 
Upping engagement with digital resources
Upping engagement with digital resourcesUpping engagement with digital resources
Upping engagement with digital resourcesLis Parcell
 
Hay vida antes del Community Manager
Hay vida antes del Community ManagerHay vida antes del Community Manager
Hay vida antes del Community ManagerDavinia Suárez
 
彩蝶计划2008版
彩蝶计划2008版彩蝶计划2008版
彩蝶计划2008版mingxia
 
Case study Online campaign của Pepsi Tết 2009
Case study Online campaign của Pepsi Tết 2009Case study Online campaign của Pepsi Tết 2009
Case study Online campaign của Pepsi Tết 2009Phuc Nguyen Thanh
 
Research Perspectives on Web 2.0 Mash-up Environments
Research Perspectives on Web 2.0 Mash-up EnvironmentsResearch Perspectives on Web 2.0 Mash-up Environments
Research Perspectives on Web 2.0 Mash-up EnvironmentsHendrik Drachsler
 
The Oracle Advisors from a Different Perspective
The Oracle Advisors from a Different PerspectiveThe Oracle Advisors from a Different Perspective
The Oracle Advisors from a Different PerspectiveKaren Morton
 
Q4M Microblogcon
Q4M MicroblogconQ4M Microblogcon
Q4M MicroblogconKazuho Oku
 
ReMashed - Recommendation in Mash-up Environments
ReMashed - Recommendation in Mash-up EnvironmentsReMashed - Recommendation in Mash-up Environments
ReMashed - Recommendation in Mash-up EnvironmentsHendrik Drachsler
 
Lyddie: Unit2 lesson5
Lyddie:  Unit2 lesson5Lyddie:  Unit2 lesson5
Lyddie: Unit2 lesson5Terri Weiss
 
Bibliografia soundscpe, sound, landscape
Bibliografia soundscpe, sound, landscapeBibliografia soundscpe, sound, landscape
Bibliografia soundscpe, sound, landscapeagata stanisz
 
Introduction to Mozilla Student Reps
Introduction to Mozilla Student RepsIntroduction to Mozilla Student Reps
Introduction to Mozilla Student RepsKinshuk Sunil
 
Tips for grabbing and holding attention in online courses
Tips for grabbing and holding attention in online coursesTips for grabbing and holding attention in online courses
Tips for grabbing and holding attention in online coursesDr Graeme Salter
 
Latvia my school-keipenes_school(1)
Latvia my school-keipenes_school(1)Latvia my school-keipenes_school(1)
Latvia my school-keipenes_school(1)Gavranica
 

En vedette (20)

Case Study on a Global Learning Program (OnlineEduca 2008 Conference Proceedi...
Case Study on a Global Learning Program (OnlineEduca 2008 Conference Proceedi...Case Study on a Global Learning Program (OnlineEduca 2008 Conference Proceedi...
Case Study on a Global Learning Program (OnlineEduca 2008 Conference Proceedi...
 
Phoenix Energy Star Bulk Purchasing Presentation
Phoenix   Energy Star Bulk Purchasing PresentationPhoenix   Energy Star Bulk Purchasing Presentation
Phoenix Energy Star Bulk Purchasing Presentation
 
Potentials and Limitations of Educational Datasets
Potentials and Limitations of Educational DatasetsPotentials and Limitations of Educational Datasets
Potentials and Limitations of Educational Datasets
 
Focus on What Matters
Focus on What MattersFocus on What Matters
Focus on What Matters
 
Unit 1.2
Unit 1.2Unit 1.2
Unit 1.2
 
Designit in Barcelona: an introduction to Generative Design
Designit in Barcelona: an introduction to Generative DesignDesignit in Barcelona: an introduction to Generative Design
Designit in Barcelona: an introduction to Generative Design
 
Upping engagement with digital resources
Upping engagement with digital resourcesUpping engagement with digital resources
Upping engagement with digital resources
 
Hay vida antes del Community Manager
Hay vida antes del Community ManagerHay vida antes del Community Manager
Hay vida antes del Community Manager
 
彩蝶计划2008版
彩蝶计划2008版彩蝶计划2008版
彩蝶计划2008版
 
Case study Online campaign của Pepsi Tết 2009
Case study Online campaign của Pepsi Tết 2009Case study Online campaign của Pepsi Tết 2009
Case study Online campaign của Pepsi Tết 2009
 
Research Perspectives on Web 2.0 Mash-up Environments
Research Perspectives on Web 2.0 Mash-up EnvironmentsResearch Perspectives on Web 2.0 Mash-up Environments
Research Perspectives on Web 2.0 Mash-up Environments
 
The Oracle Advisors from a Different Perspective
The Oracle Advisors from a Different PerspectiveThe Oracle Advisors from a Different Perspective
The Oracle Advisors from a Different Perspective
 
Q4M Microblogcon
Q4M MicroblogconQ4M Microblogcon
Q4M Microblogcon
 
Toronto
TorontoToronto
Toronto
 
ReMashed - Recommendation in Mash-up Environments
ReMashed - Recommendation in Mash-up EnvironmentsReMashed - Recommendation in Mash-up Environments
ReMashed - Recommendation in Mash-up Environments
 
Lyddie: Unit2 lesson5
Lyddie:  Unit2 lesson5Lyddie:  Unit2 lesson5
Lyddie: Unit2 lesson5
 
Bibliografia soundscpe, sound, landscape
Bibliografia soundscpe, sound, landscapeBibliografia soundscpe, sound, landscape
Bibliografia soundscpe, sound, landscape
 
Introduction to Mozilla Student Reps
Introduction to Mozilla Student RepsIntroduction to Mozilla Student Reps
Introduction to Mozilla Student Reps
 
Tips for grabbing and holding attention in online courses
Tips for grabbing and holding attention in online coursesTips for grabbing and holding attention in online courses
Tips for grabbing and holding attention in online courses
 
Latvia my school-keipenes_school(1)
Latvia my school-keipenes_school(1)Latvia my school-keipenes_school(1)
Latvia my school-keipenes_school(1)
 

Similaire à Why Perl, when you can use bash+awk+sed? :P

PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!Blanca Mancilla
 
Unix command-line tools
Unix command-line toolsUnix command-line tools
Unix command-line toolsEric Wilson
 
Writing Modular Command-line Apps with App::Cmd
Writing Modular Command-line Apps with App::CmdWriting Modular Command-line Apps with App::Cmd
Writing Modular Command-line Apps with App::CmdRicardo Signes
 
WordPress in 30 minutes
WordPress in 30 minutesWordPress in 30 minutes
WordPress in 30 minutesOwen Winkler
 
Barely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationBarely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationAttila Balazs
 
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...Andrea Telatin
 
Recursive descent parsing
Recursive descent parsingRecursive descent parsing
Recursive descent parsingBoy Baukema
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsAbhay Sapru
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsDr.Ravi
 
[Erlang LT] Regexp Perl And Port
[Erlang LT] Regexp Perl And Port[Erlang LT] Regexp Perl And Port
[Erlang LT] Regexp Perl And PortKeiichi Daiba
 
Erlang with Regexp Perl And Port
Erlang with Regexp Perl And PortErlang with Regexp Perl And Port
Erlang with Regexp Perl And PortKeiichi Daiba
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Andrea Telatin
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
 

Similaire à Why Perl, when you can use bash+awk+sed? :P (20)

PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!
 
Unix command-line tools
Unix command-line toolsUnix command-line tools
Unix command-line tools
 
Shell Script
Shell ScriptShell Script
Shell Script
 
Writing Modular Command-line Apps with App::Cmd
Writing Modular Command-line Apps with App::CmdWriting Modular Command-line Apps with App::Cmd
Writing Modular Command-line Apps with App::Cmd
 
Perl basics for Pentesters
Perl basics for PentestersPerl basics for Pentesters
Perl basics for Pentesters
 
WordPress in 30 minutes
WordPress in 30 minutesWordPress in 30 minutes
WordPress in 30 minutes
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
Barely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationBarely Legal Xxx Perl Presentation
Barely Legal Xxx Perl Presentation
 
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
 
Recursive descent parsing
Recursive descent parsingRecursive descent parsing
Recursive descent parsing
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
[Erlang LT] Regexp Perl And Port
[Erlang LT] Regexp Perl And Port[Erlang LT] Regexp Perl And Port
[Erlang LT] Regexp Perl And Port
 
Erlang with Regexp Perl And Port
Erlang with Regexp Perl And PortErlang with Regexp Perl And Port
Erlang with Regexp Perl And Port
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
Unix tips and tricks
Unix tips and tricksUnix tips and tricks
Unix tips and tricks
 
Bioinformatica p4-io
Bioinformatica p4-ioBioinformatica p4-io
Bioinformatica p4-io
 

Plus de Luciano Rocha

Perl From Vi, Part I
Perl From Vi, Part IPerl From Vi, Part I
Perl From Vi, Part ILuciano Rocha
 
Gil - Virtualisation and High Availability
Gil - Virtualisation and High AvailabilityGil - Virtualisation and High Availability
Gil - Virtualisation and High AvailabilityLuciano Rocha
 
Gil - LiveCDs and Virtualisation, 2006
Gil - LiveCDs and Virtualisation, 2006Gil - LiveCDs and Virtualisation, 2006
Gil - LiveCDs and Virtualisation, 2006Luciano Rocha
 
Gil - LiveCDs and Virtualisation, 2005
Gil - LiveCDs and Virtualisation, 2005Gil - LiveCDs and Virtualisation, 2005
Gil - LiveCDs and Virtualisation, 2005Luciano Rocha
 
Managing Plone Projects with Perl and Subversion
Managing Plone Projects with Perl and SubversionManaging Plone Projects with Perl and Subversion
Managing Plone Projects with Perl and SubversionLuciano Rocha
 

Plus de Luciano Rocha (6)

Agile Memcached
Agile MemcachedAgile Memcached
Agile Memcached
 
Perl From Vi, Part I
Perl From Vi, Part IPerl From Vi, Part I
Perl From Vi, Part I
 
Gil - Virtualisation and High Availability
Gil - Virtualisation and High AvailabilityGil - Virtualisation and High Availability
Gil - Virtualisation and High Availability
 
Gil - LiveCDs and Virtualisation, 2006
Gil - LiveCDs and Virtualisation, 2006Gil - LiveCDs and Virtualisation, 2006
Gil - LiveCDs and Virtualisation, 2006
 
Gil - LiveCDs and Virtualisation, 2005
Gil - LiveCDs and Virtualisation, 2005Gil - LiveCDs and Virtualisation, 2005
Gil - LiveCDs and Virtualisation, 2005
 
Managing Plone Projects with Perl and Subversion
Managing Plone Projects with Perl and SubversionManaging Plone Projects with Perl and Subversion
Managing Plone Projects with Perl and Subversion
 

Dernier

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 

Dernier (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 

Why Perl, when you can use bash+awk+sed? :P

  • 1. Why Perl, when you can use bash+awk+sed? :P Luciano Rocha June 6th, 2008
  • 2. Introduction 1 What’s your excuse? 2 The hand is faster than the mind! 3 What if... 4 No more hunting! 5 Vrooom!
  • 3. What’s your excuse (or, Learn your tools) Increase productivity Having a profound understanding of the tools you interact with daily will increase your productivity immensely. Example: shell history $ wget h t t p : / / . . . / r s y s l o g −3.19.6. t a r . gz ... $ tar xf ! $ : t t a r x f r s y s l o g −3.19.6. t a r . gz $
  • 4. Learn your tools, cont. Example: extended globs # rpm −Uvh . . . / RPMS/ i 3 8 6 / postgres −∗ E r r o r : something r e q u i r e s p g s q l # rpm −i v h ! $ : h / p o s t r e s q l−l i b s ∗ # i n s t a l l l i b # rpm −Uvh ! $ : h / p o s t g r e s q l −!( t e s t ∗ | d e b u g i n f o ∗ | l i b s ∗) # upgrade t o o l s ... # # r e b u i l d dependencies Example: lib dependencies $ f i n d . −type f −perm −u+x −o −name ∗ . so | xargs r e a d e l f −d 2 >/ dev / n u l l | sed −ne ’ /NEED/ s , . ∗ [ ( . ∗ ) ] , 1 , p ’ | s o r t −u l i b a s o u n d . so . 2 l i b c o m _ e r r . so . 2 l i b c r y p t o . so . 6 l i b c r y p t o . so . 7 ...
  • 5. Learn your tools, cont. Example: fix track numbers $ f o r f i n ∗ .mp3 ; do i d 3 v 2 −T quot; $ { f%%[ −.]∗} quot; quot; $ f quot; ; done Example: remove empty files $ f i n d . −type f −s i z e 0 −p r i n t 0 | xargs −r 0 rm −f Example: create archive without ‘.svn’ $ f i n d . −name . svn −prune −o −p r i n t | c p i o −o | g z i p −9 > source . cgz
  • 6. The hand is faster than the mind! (Or, Think as you type) Mechanize Entering common commands becomes mechanical, and leaves you time to think the solution: Do ‘command’ to some files: find . ... | xargs −r . . . fix files: f o r i i n . . . ; do . . ; done
  • 7. What if... (or, Incremental solutions) Incremental solutions Keep trying until you arrive to the correct solution. Example: find largest file $ f i n d . −type f | xargs −r s t a t −c quot;%s %n quot; | s o r t −r n | head Example: usb device associated with a disk $ p=$ ( udevadm i n f o −−path = / sys / b l o c k / sdc −−query=path ) $ udevadm i n f o −e | grep −B1 bus / usb / | while read p sys && read n dev && read dash ; do echo $sys $dev ; done | LANG=C s o r t | while read sys dev ; do i f echo $p | f g r e p −q − − $sys ; then echo $dev ; break ; f i ; done
  • 8. No more hunting! (or, Fewer dependencies) Standard Unix R tools Perl isn’t always available, or with the packages you desire: $ ... Can ’ t l o c a t e A : : B i n @INC . . . $ yum −y i n s t a l l ’ p e r l (A : : B ) ’ ( wait ) ... Nothing t o do $ cpan A : : B −bash : cpan : command n o t found $ p e r l −MCPAN −e s h e l l install A::B ( wait ) ( t r i e s f t p , not possible i n s i d e t h i s f i r e w a l l ) ^C ^C Easier to learn The documentation for those tools are tiny, compared to Perl’s.
  • 9. Vrooom! (or, Low overhead) Small and fast utilities Sometimes, you’ll be restricted in space, like in an initrd, or on the time a script takes to execute: $ t i m e awk / dev / n u l l < / dev / n u l l 0.010 s $ ^awk^ p e r l 0.023 s Example: Xen bridge script n e t c o n f _ i p = quot; $ ( i p addr show dev $1 | awk −v ORS= quot; quot; ’ $1 == quot; i n e t quot; | | $1 == quot; i n e t 6 quot; { p r i n t quot; i p addr add quot; $2 ; i f ( $3 == quot; brd quot; ) p r i n t quot; brd quot; $4 ; p r i n t quot; dev $dev ; quot; ; } ’) quot;