Other responses have latched on to perl -e and that's probably one good avenue to explore. Here's a real-world example for you. I recently downloaded a bunch of files from a Windows system and uploaded them to a FreeBSD system, only to find that the spaces in the file names had been encoded so they were now '%20'. I had to rename three directories, each containing six files.

After wimping out on the first two directories (this was time critical stuff and it was after midnight, a great time for making dumb mistakes, especially after a jam-packed 11 hour work day) I wrote

perl -e 'while(<*.mp3>){$orig=$_;s/%20/ /;print"$orig -> $_\n";}'
That seemed OK, but then I realized I'd have to escape the space in the middle of the name, so finally I wrote
perl -e 'while(<*.mp3>){$orig=$_;s/%20/\\ /;print`mv -v $orig $_`;}'
I ran it, and the verbose option confirmed that I'd done it correctly.

So what did that require that I wouldn't have had a clue how to do as a beginner?

Well, that's not exactly an earth-shatteringly important list, but that's what I can squeeze out of that lemon.

Alex / talexb / Toronto

Life is short: get busy!


In reply to Re: Easy Things (part I) by talexb
in thread Easy Things by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.