• Home
  • Shell
    • Emacs
    • Perl
    • screen
    • sed
  • Ubuntu
    • VNC
  • Web Development
    • Javascript
    • Joomla
    • MySQL
    • osTicket
  • Windows
    • Gimp

Posts in category Perl

Web Dev> Obtaining Google PageRank

Jun06
2012
Written by Scott Rowley

As a part of Search Engine Optimization (SEO) you may want to be aware of your websites (or clients websites) page rank on Google. After some researching I’ve found the following solutions to be best. I’ll be presenting a few options here, first we’ll cover how to look it up on prchecker.info. Second we’ll be covering how to look up the page rank using a perl script and finally we’ll cover how to look up your page rank with the perl script and update a mysql database with the information (for long term tracking and/or tracking multiple websites.)
READ MORE »

Posted in MySQL, PHP, SEO, Web Development - Tagged database, google, MySQL, page, page rank, php, prchecker.info, rank, script, search engine optimizaiton, SEO

Perl> Useful one-liners

Dec08
2010
Written by Scott Rowley

Remove string from file

perl -ni -e 'print unless /pattern/' /path/to/filename

Replace string with string

perl -p -i -e 's/PATTERN/NEW_ENTRY/g' /path/to/filename

Insert string where delimeter is found
This will replace the original delimiter with the new entry and then add the delimiter so you can use it again in the future.

perl -p -i -e 's/DELIMETER/NEW_ENTRY\n\nDELIMETER/g' /path/to/filename

This will grab anything thats in the standard IPv4 format (anything! not always IPs…but usually).

perl -ne 'print "$&\n" while m#\d+\.\d+\.\d+\.\d+#g' file.txt

Search for and find whole paragraphs containing $string

perl -00ne "print if /$string/i" < file.txt
Tagged delimiter, insert, liner, one, one-liner, remove, replace, string, variable

Perl> Get IP only from logfiles

Oct26
2010
Written by Scott Rowley

Being an ISP admin, I have regular need to find IP addresses listed in large logfiles. The following will grab anything that appears to be an IP and list it out for you, from there you can sort or whatever you want to do with the list.

perl -ne 'print "$&n" while m#d+.d+.d+.d+#g' <logfile>

Or just throw it in a bash script for easier remembering:

getip.sh

#!/bin/bash
perl -ne 'print "$&\n" while m#\d+\.\d+\.\d+\.\d+#g' $1;
Tagged BASH, IP, log, logfile, print

Corrections? Questions? Comments?

Find an error?
Everything work out great for you?
Have some feedback?
Like to see something added to the article?

PLEASE leave us a comment after the article and let us know how we are doing, or if something needs corrected, improved or clarified.

Thank you!
- The Management

Advertisement

Sudo Bash
By Geeks - For Geeks

Back to Top