Convert perl one-liner into a script

Posted by Stefan Lasiewski on Stack Overflow See other posts from Stack Overflow or by Stefan Lasiewski
Published on 2010-05-12T20:30:21Z Indexed on 2010/05/12 20:34 UTC
Read the original article Hit count: 351

Filed under:
|

I find alot of perl one-liners online. Sometimes I want to convert these one-liners into a script, because otherwise I'll forget the syntax of the one-liner.

For example, I'm using the following command (from nagios.com):

tail -f /var/log/nagios/nagios.log | perl -pe 's/(\d+)/localtime/e'

I'd to replace it with something like this:

tail -f /var/log/nagios/nagios.log | ~/bin/nagiostime.pl

However, I can't figure out the best way to quickly throw this stuff into a script. Does anyone have a quick way to throw these one-liners into a Bash or Perl script?

© Stack Overflow or respective owner

Related posts about perl

Related posts about command-line