I have a bunch of text files and I want to move them to Windows (which as usually only follows one standard (it's own) and is unable to properly interpret Unix line breaks (unlike most Unix text-tools that can manage both standards)). If I just move them they will look horrible and my client will complain. So, what to do. Time to deploy a friendly Perl hacker (fadern), which I happen to know. Tinker a bit and soon you will have a one-liner that solves your problem.
Unix -> Windows
> perl -pi'.bak' -e 's/\012/\015\012/g' *.suffix
Windows -> Unix
> perl -pi'.bak' -e 's/\015\012/\012/g' *.suffix
These commands will create backups of the changed files with a .bak suffix. If you feel that you don't need that just remove '.bak' from the command. Just remember that if you screw up it's permanent.
Showing posts with label scripting. Show all posts
Showing posts with label scripting. Show all posts
Thursday, 3 May 2007
Subscribe to:
Posts (Atom)