• Perls before swine

    From Angus McLeod@VERT/ANJO to All on Tuesday, June 20, 2006 00:55:00
    Convert a file with Ctrl-A characters to use \1's that are more easily
    edited:

    perl -i -pe 's/\\1/\x01/g' somefile.ext

    Convert \1's back to Ctrl-A's:

    perl -i -pe 's/\x01/\\1/g' somefile.ext

    Multiple files to convert? Just add more filenames on the end of the
    command.

    Files converted 'in situ'. To keep a backup of the original add an
    extension after the -i switch like:

    perl -i.BAK -pe 's/\\1/\x01/g' somefile.ext

    or remove the -i switch entirely and redirect STDOUT to a file to hold the results of the conversion:

    perl -pe 's/\x01/\\1/g' somefile.ext > converted.out

    But this prevents multiple file conversion (unless you want the output combined into a single result file).

    These one-liners make good bash aliases or shell scripts.

    ---
    Playing: "The death song" by "Marilyn Manson"
    from the "Holy wood" album
    þ Synchronet þ Programatically generated on The ANJO BBS
  • From Deuce@VERT/SYNCNIX to Angus McLeod on Tuesday, June 20, 2006 00:03:00
    Re: Perls before swine
    By: Angus McLeod to All on Tue Jun 20 2006 12:55 am

    Convert a file with Ctrl-A characters to use \1's that are more easily edited:

    perl -i -pe 's/\\1/\x01/g' somefile.ext

    Convert \1's back to Ctrl-A's:

    perl -i -pe 's/\x01/\\1/g' somefile.ext

    *blink*

    Or vice-versa.

    ---
    I find pleasure in knowing... this colours my words enough that people think I enjoy proving them wrong. Howver, I would be just as happy being proven wrong and knowing more than proving myself right. Please understand that any perceived rudeness is not intended. Rest assured that should I feel like being purposely rude, I will insult you personally and not attack your knowledge.

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Angus McLeod@VERT/ANJO to Deuce on Tuesday, June 20, 2006 09:18:00
    Re: Perls before swine
    By: Deuce to Angus McLeod on Tue Jun 20 2006 00:03:00

    Convert a file with Ctrl-A characters to use \1's that are more easily edited:

    perl -i -pe 's/\\1/\x01/g' somefile.ext

    Convert \1's back to Ctrl-A's:

    perl -i -pe 's/\x01/\\1/g' somefile.ext

    *blink*

    Or vice-versa.

    LOL! Seems like I when I cut'n'pasted I shoulda pasted'n'cut instead!
    ---
    Playing: "Gaayatri" by "Ravi Shankar"
    from the "Chants of India" album
    þ Synchronet þ Programatically generated on The ANJO BBS