Dark background with blue accents with light reflectionsDark background with blue accents with light reflectionsDark background with blue accents with light reflections
[Mac OS X] Convert texts on the command line

[Mac OS X] Convert texts on the command line

[Mac OS X] Converting Texts on the Command Line

Continuing our exploration of command line capabilities in OS X. This time we will deal with text files in various formats and converting them from one format to another.

Of course, in OS X there is a tool for this task. 🙂

And its name is a utility that can convert formats:

txt, html, rtf, rtfd, doc, docx, wordml, odt, webarchive

from one to another.

Using the utility is quite simple. I'll give you an example right away.
With TextEdit. app I prepared a test file :

(all images are clickable)

Let's convert it, for example, to docx format:

Check what happened:

Or, for example, in html:

Checking:

Let's try something a little more interesting. Let's create a file in doc format directly from the command line. To do this, we will take as a text source not a text file, but the so-called Standard Input (standard input) - stdin. Execute the command:

After running for execution, the command will move the cursor to the next line and wait for text input. Enter the desired text, and upon completion of the input, press the combination Ctrl+D:

And check what happened - :

You can also check the file with the utility itself:

All features of the utility, as always, can be viewed using the command or .

Good luck!



Read this article in other languages: