Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: What one-liners do people actually use?

by strat (Canon)
on Dec 09, 2005 at 08:37 UTC ( #515484=note: print w/replies, xml ) Need Help??


in reply to What one-liners do people actually use?

My most important one liner: if I set up some coffee and continue working, I often forget to fetch it, and it gets cold... so:

perl -le 'sleep(300); print qq~\a~ x 10'

reminds me that I must not forget to fetch the fresh coffee; this is the oneliner I use most often

other cases, for filtering or replacing data in files, e.g. printing objects in LDIF files which have the auxiliary object class dxmADsUser:

perl -e 'BEGIN { $/="\n\n" }' -ne 'print if /^objectClass: dxmADsUser/si' file1 > file2

or replacing domain components on-the-fly:

perl -i.bak -pe 's/dc=domain1,dc=tld$/dc=domain2,dc=tld/' file

or counting something, e.g. how often each attribute is existing in an ldif file:

perl -MData::Dumper -ane '$count_of{$F[0]}++' -e 'END { print Dumper(\%count_of) }' file

Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

Replies are listed 'Best First'.
Re^2: What one-liners do people actually use?
by Anonymous Monk on Dec 10, 2005 at 22:52 UTC
    Learn the -0 switch. :-)
    perl -00ne'print if /^objectClass: dxmADsUser/i' file1 > file2

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://515484]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2016-12-09 09:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (150 votes). Check out past polls.