<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr - noah</title>
<link>http://snipplr.com/users/noah/tags/file</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Tue, 14 Feb 2012 23:56:47 GMT</pubDate>
<item>
<title>(Bash) sendmail without writing a file</title>
<link>http://snipplr.com/view/40790/sendmail-without-writing-a-file/</link>
<description><![CDATA[ <p>Usually you see sendmail invoked with `sendmail me@example.com < file.txt`

What if you're scripting, and don't feel like writing a temp file for every email message?</p> ]]></description>
<pubDate>Tue, 21 Sep 2010 00:22:32 GMT</pubDate>
<guid>http://snipplr.com/view/40790/sendmail-without-writing-a-file/</guid>
</item>
<item>
<title>(SVN) Howto list all the file extension types in an SVN log dump</title>
<link>http://snipplr.com/view/28195/howto-list-all-the-file-extension-types-in-an-svn-log-dump/</link>
<description><![CDATA[ <p>Note that on Windows you will want to double-quote the string argument to `perl -ne` rather than single-quoting it.  Otherwise this works on Windows (with Cygwin) as well.</p> ]]></description>
<pubDate>Thu, 11 Feb 2010 14:59:31 GMT</pubDate>
<guid>http://snipplr.com/view/28195/howto-list-all-the-file-extension-types-in-an-svn-log-dump/</guid>
</item>
<item>
<title>(Bash) Log4r: how to use RollingFileOutputter: automatically cycle stale logfiles</title>
<link>http://snipplr.com/view/26962/log4r-how-to-use-rollingfileoutputter-automatically-cycle-stale-logfiles/</link>
<description><![CDATA[ <p>(Log4r::RollingFileOutputter)(http://log4r.sourceforge.net/rdoc/files/log4r/formatter/formatter_rb.html) automatically renames/archives log files once they get too big or too old.

This is not my code, I found it [in Google's cache](http://74.125.93.132/search?q=cache:NH-CfIj0MhQJ:omf.mytestbed.net/repositories/entry/omf/branches/reorg/log4r-1.0.5/examples/fileroll.rb%3Fformat%3Draw%26rev%3D89+log4r+rollingfileoutputter) and I found it useful, so I figured I should preserve it.  If you're the author, get in touch and I'll credit/link you (and thanks!)</p> ]]></description>
<pubDate>Sun, 24 Jan 2010 15:18:50 GMT</pubDate>
<guid>http://snipplr.com/view/26962/log4r-how-to-use-rollingfileoutputter-automatically-cycle-stale-logfiles/</guid>
</item>
<item>
<title>(Bash) Grep for files that do not match a pattern</title>
<link>http://snipplr.com/view/16699/grep-for-files-that-do-not-match-a-pattern/</link>
<description><![CDATA[ <p>The -L option lists files that do *not* contain a line matching the pattern given.</p> ]]></description>
<pubDate>Mon, 06 Jul 2009 16:37:12 GMT</pubDate>
<guid>http://snipplr.com/view/16699/grep-for-files-that-do-not-match-a-pattern/</guid>
</item>
<item>
<title>(Perl) comparing the checksums of two files with Perl and cksum</title>
<link>http://snipplr.com/view/16660/comparing-the-checksums-of-two-files-with-perl-and-cksum/</link>
<description><![CDATA[ <p>This one-liner helps to determine if two or more files have the same
checksum.  It works by piping the output from `cksum` to Perl, which
takes note of the first checksum and compares each subsequent file's
checksum to that value.

Assume an example session where we have three identical files and two
that are different
      
    >echo bart > bart
    >cp bart bart1
    >cp bart bart2
    >echo milhouse > mvh
    >echo lisa > lisa
      
two files with the same checksum, produce no output
      
    >cksum bart bart1 | perl -ane '$x ||= $F[0]; warn if $x != $F[0];'
      
if a there is a different checksum, the line numbers printed are the
indexes of those files
      
    >cksum bart bart1 mvh bart2 lisa | perl -ane '$x ||= $F[0]; warn if $x != $F[0];'
    Warning: something's wrong at -e line 1,  line 3.
    Warning: something's wrong at -e line 1,  line 5.</p> ]]></description>
<pubDate>Sun, 05 Jul 2009 21:17:39 GMT</pubDate>
<guid>http://snipplr.com/view/16660/comparing-the-checksums-of-two-files-with-perl-and-cksum/</guid>
</item>
<item>
<title>(Bash) Alias a command and save it in .profile</title>
<link>http://snipplr.com/view/7400/alias-a-command-and-save-it-in-profile/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sat, 19 Jul 2008 13:03:50 GMT</pubDate>
<guid>http://snipplr.com/view/7400/alias-a-command-and-save-it-in-profile/</guid>
</item>
<item>
<title>(Bash) tar basics</title>
<link>http://snipplr.com/view/7399/tar-basics/</link>
<description><![CDATA[ <p>You would think I'd have this memorized by now, but no.</p> ]]></description>
<pubDate>Sat, 19 Jul 2008 12:29:59 GMT</pubDate>
<guid>http://snipplr.com/view/7399/tar-basics/</guid>
</item>
<item>
<title>(Perl) age of file?</title>
<link>http://snipplr.com/view/3137/age-of-file/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 03 Jul 2007 23:06:47 GMT</pubDate>
<guid>http://snipplr.com/view/3137/age-of-file/</guid>
</item>
<item>
<title>(Perl) create new files</title>
<link>http://snipplr.com/view/3132/create-new-files/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 03 Jul 2007 22:50:04 GMT</pubDate>
<guid>http://snipplr.com/view/3132/create-new-files/</guid>
</item>
<item>
<title>(Perl) id3.pl</title>
<link>http://snipplr.com/view/3129/id3pl/</link>
<description><![CDATA[ <p>This script takes a list of directories as its argument. 
  For mp3s that don't have any id3 information, guess      
  the name of the artist and track based on the filename   
  and use the MP3-Info module to insert that guess into    
  the file as id3v1 tags.</p> ]]></description>
<pubDate>Tue, 03 Jul 2007 22:40:18 GMT</pubDate>
<guid>http://snipplr.com/view/3129/id3pl/</guid>
</item>
<item>
<title>(Perl) Move MP3s into Artist/Album folders</title>
<link>http://snipplr.com/view/3128/move-mp3s-into-artistalbum-folders/</link>
<description><![CDATA[ <p>Given a directory of MP3s, read the ID3 tags and reorganize the directory so that all of the MP3s reside in folders that are nested in the order: Artist/Album/File.mp3</p> ]]></description>
<pubDate>Tue, 03 Jul 2007 22:37:20 GMT</pubDate>
<guid>http://snipplr.com/view/3128/move-mp3s-into-artistalbum-folders/</guid>
</item>
<item>
<title>(Perl) Truncate filenames but keep file extensions intact</title>
<link>http://snipplr.com/view/3127/truncate-filenames-but-keep-file-extensions-intact/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 03 Jul 2007 22:33:28 GMT</pubDate>
<guid>http://snipplr.com/view/3127/truncate-filenames-but-keep-file-extensions-intact/</guid>
</item>
<item>
<title>(Perl) Grab linked files from a list of web pages</title>
<link>http://snipplr.com/view/3126/grab-linked-files-from-a-list-of-web-pages/</link>
<description><![CDATA[ <p>## how to use

`perl grabit.pl urls_for_download.txt`

Expects as argument the name of a file containing a newline-delimited list of URLs:

    http://example.com/coolstuff
    http://example.com/coolstuff/fun
    http://example.com/videos/explosions

When invoked, launches an interactive shell that asks what type of file should be downloaded.  Then downloads all the files that are linked from each of the listed Web pages.

Note that the location of the download folder is hard-coded to `c:/windows/desktop/grabit/` so you may want to change that before trying.

This script is also [available on Github](http://github.com/textarcana/scrapers/blob/643e6e7cb349fa94cbc3fc88e1d55c7b6a262d11/grabit.pl)

## Wait! Do you know about WGet and Curl?

This script is legacy.  People seem to like it (hey, I still use it) but today I would probably not write my own tool to download multiple files off remote sites.

Instead I would likely just use a command-line Web browser like [WGet](http://lifehacker.com/software/top/geek-to-live--mastering-wget-161202.php 'Gina Trapani of Lifehacker, on the way of the WGet ninja') or Curl.  [LWP-Request would also do the trick](http://snipplr.com/view/4063/download-linked-jpegs-from-a-web-page-on-the-command-line/)

## do not comment your code like this!

For a great explanation of the rather baroque commenting style I was using circa 2001, see [Steve Yegge's excellent article on code style: *Portait of a n00b.*](http://steve-yegge.blogspot.com/2008/02/portrait-of-n00b.html)  

Of course, when I sit down to write a Perl script today, I [use POD](http://snipplr.com/view/18611/perl-pod-embedded-documentation-example/) to format and publish my comments.</p> ]]></description>
<pubDate>Tue, 03 Jul 2007 22:31:30 GMT</pubDate>
<guid>http://snipplr.com/view/3126/grab-linked-files-from-a-list-of-web-pages/</guid>
</item>
<item>
<title>(Perl) Remove duplicate lines from a text file with Perl</title>
<link>http://snipplr.com/view/3124/remove-duplicate-lines-from-a-text-file-with-perl/</link>
<description><![CDATA[ <p>*[Found at Google Answers.](http://answers.google.com/answers/threadview?id=25196)*

Sometimes I get a big list of things, and some of the things occur multiple times in the same list.  To make the list easier to read, I want to *delete* the duplicate lines.
 
A good example is a list of files that have errors (maybe excerpted from an application sever's log files).  In that case you have a newline-delimited list of file paths,  and depending upon the situation, the same file path might be listed 4 or 5 times or more.  Often, it is useful to have a list of just the files that are faulty, which can be produced by deleting all the duplicate lines.  This script is for filtering just those kinds of list files.

[Of course,](http://xkcd.com/378/ "emacs has a command for that")  for **Emacs** users  [there is a much easier way to remove duplicate lines:](http://everything2.com/title/useful%2520emacs%2520lisp%2520functions "useful emacs lisp functions"), if you have `uniq` installed on your system.

`M-x sort-lines RET C-x h M-x shell-command-on-region RET uniq RET`</p> ]]></description>
<pubDate>Tue, 03 Jul 2007 22:06:34 GMT</pubDate>
<guid>http://snipplr.com/view/3124/remove-duplicate-lines-from-a-text-file-with-perl/</guid>
</item>
<item>
<title>(Perl) Make a list of JPEGs into a slide show</title>
<link>http://snipplr.com/view/3123/make-a-list-of-jpegs-into-a-slide-show/</link>
<description><![CDATA[ <p>Show jpegs one-per-page on a series of hyperlinked web pages.  Purpose was to provide a linear viewing mechanism for jpegs on my Palm Tungsten C.</p> ]]></description>
<pubDate>Tue, 03 Jul 2007 22:02:15 GMT</pubDate>
<guid>http://snipplr.com/view/3123/make-a-list-of-jpegs-into-a-slide-show/</guid>
</item>
<item>
<title>(Perl) Show JPEGs in this directory all on one page</title>
<link>http://snipplr.com/view/3122/show-jpegs-in-this-directory-all-on-one-page/</link>
<description><![CDATA[ <p>Dumps a list of image names into an HTML document, wrapped in centered IMG tags.  Features the CENTER tag for added historical value.</p> ]]></description>
<pubDate>Tue, 03 Jul 2007 21:57:11 GMT</pubDate>
<guid>http://snipplr.com/view/3122/show-jpegs-in-this-directory-all-on-one-page/</guid>
</item>
<item>
<title>(Perl) show JPEGs in this directory in a simple HTML gallery</title>
<link>http://snipplr.com/view/3121/show-jpegs-in-this-directory-in-a-simple-html-gallery/</link>
<description><![CDATA[ <p>Creates an HTML page with the first image in the directory in the center.  Forward and Back buttons scroll through all the images in the directory in order.

This is how I lived before Firefox ~.^</p> ]]></description>
<pubDate>Tue, 03 Jul 2007 21:53:26 GMT</pubDate>
<guid>http://snipplr.com/view/3121/show-jpegs-in-this-directory-in-a-simple-html-gallery/</guid>
</item>
<item>
<title>(Lisp) load an external file</title>
<link>http://snipplr.com/view/2933/load-an-external-file/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 18 Jun 2007 20:48:42 GMT</pubDate>
<guid>http://snipplr.com/view/2933/load-an-external-file/</guid>
</item>
<item>
<title>(Perl) Text change across multiple files</title>
<link>http://snipplr.com/view/2034/text-change-across-multiple-files/</link>
<description><![CDATA[ <p>Put this in a script called "update.pl" and call it with "ls *ext|xargs perl update.pl"  Be sure to back up the work directory before playing with this, as it is very easy to wipe out the content of a bunch of files at once in this way.</p> ]]></description>
<pubDate>Sun, 28 Jan 2007 09:01:18 GMT</pubDate>
<guid>http://snipplr.com/view/2034/text-change-across-multiple-files/</guid>
</item>
<item>
<title>(Bash) Find/Grep for a string across multiple files with different extensions</title>
<link>http://snipplr.com/view/2033/findgrep-for-a-string-across-multiple-files-with-different-extensions/</link>
<description><![CDATA[ <p>Search many files for a string.  This example finds the string "thingy."  This is useful when I want to find, say, a CSS class name that has changed, and update it in all of my .js, .jsp and .jspf files.  

The -niP argument to grep is optional.  -n prints line numbers, -i makes search case-insensitive, and -P toggles Perl regular expression syntax.  (I'm not sure that -P works under Cygwin.)</p> ]]></description>
<pubDate>Sun, 28 Jan 2007 07:43:53 GMT</pubDate>
<guid>http://snipplr.com/view/2033/findgrep-for-a-string-across-multiple-files-with-different-extensions/</guid>
</item>
</channel>
</rss>
