Showing posts with label oneliners. Show all posts
Showing posts with label oneliners. Show all posts

Saturday, 9 January 2010

Not so "diff"-icult after all

I've gone back and updated the way that the filename formatter would work on the command line, and it turns out that on the command line, it's a lot simpler than I'd previously thought.  So here's the ammended version:

perl -e 'print join("\\ ", @ARGV)' [FILE NAME]
I also feel no shame in using yet another "diff" based pun in the title.


Friday, 8 January 2010

A "diff"-icult problem

Sorry, I couldn't help myself.

Writing the file copying routines for the "diff for folders", I've come across the small problem of converting from the non-escaped versions of file names that readdir produces, to the escaped versions that the shell commands need.  I have, however, managed to produce a imho pretty nice oneliner to do this.
join("\\ ", split(/ /, $fileName));
 Which takes a file name like "some random file.txt" and converts it to "some\ random\ file.txt". Obviously, this won't work directly from the command line yet, but when I've got more time I'm going to adapt it to do so.