Is there something like a 'lorem ipsum generator'? I know it exists in Latex, and even in LibreOffice, but I'm looking for a terminal command. I would like to type something like loremipsum 10 >> file1.txt that would give me the first 10 paragraphs of lorem ipsum, each paragraph ended with one LF-character and 1 empty white line between each paragaph. And the output would be redirected to a file called file1.txt in the current directory.


You can use the perl library libtext-lorem-perl. Here a short example, feel free to expand it to parse command line arguments, etc.

#!/usr/bin/env perl

use Text::Lorem;

my $text = Text::Lorem->new();
$paragraphs = $text->paragraphs(10);

print $paragraphs;
  • 1
    i got this error: Can't locate Text/Lorem.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at ./loremipsum.pl line 3. BEGIN failed--compilation aborted at ./loremipsum.pl line 3. – Frank Oct 22 '13 at 22:12
  • 1
    Sorry, I didn't install the libtext-lorem-perl package. Will try again. – Frank Oct 22 '13 at 22:16
  • 3
    On Debian the libtext-lorem-perl package contains simple lorem command, so there is no urgent need for custom scripts. – Josef Kufner Dec 29 '14 at 16:44

found this at Bash One-Liners

 tr -dc a-z1-4 </dev/urandom | tr 1-2 ' \n' | awk 'length==0 || length>50' | tr 3-4 ' ' | sed 's/^ *//' | cat -s | sed 's/ / /g' |fmt

must be limited by another command or generates text infintely

  • 2
    fails on OS X 10.10 with tr: Illegal byte sequence – ssc Sep 22 '16 at 13:00
  • 2
    Random words are not the real thing though. – user877329 Jan 25 '17 at 11:04
  • 1
    @ssc Try installing GNU tr (brew install coreutils) and replace tr with gtr. – jlowgren May 16 '17 at 12:45
  • tr on a Mac doesn't behave the same as on Linux. See this post: unix.stackexchange.com/questions/141420/… – Adam Oct 3 '18 at 18:35

Fedora has a lorem-ipsum-generator package :

lorem-ipsum-generator -p 10 -l

will do exactly what you are asking for.

Another DIY alternative :

info bash -o -|shuf -n50|sed 's/  */ /g;s/^ //'|fmt -w 90

This outputs bash documentation into stdout, pipes it to shuf which randomly selects 50 lines, then sed removes multiple and leading spaces, and finally fmt formats it to lines approximately 90 characters long.

Of course this is just a starting point and you might need to refine the output, for which sed, tr and other string manipulators will help.

shuf, fmt and tr are parts of coreutils (which has a great chance of being already installed on your GNU/Linux distribution).

  • I fixed up your sed program a little bit and added a head to the pipe so you can select the number of lines you want: info -a bash -o - | shuf -n50 | sed -n 's/ */ /g;s/^ //;/./p' | fmt -w 90 | head -8 – OscarJ Apr 13 at 15:21

The following command has been useful for me in many situations:

base64 /dev/urandom | awk '{print(0==NR%10)?"":$1}' | sed 's/[^[:alpha:]]/ /g' | head -50

This gives 50 lines where non-alphabetical characters obtained randomly from base64 /dev/urandom have been replaced by blank spaces: sed 's/[^[:alpha:]]/ /g'. Each line whose index is a multiple of 10 is replaced by the empty string (in order to simulate separation of paragraphs): awk '{print(0==NR%10)?"":$1}'.

You can add | awk '{ print NR,$0 }' at the end to get numbered lines (or any other that meets your needs). An executable bash-script lipsum that accepts the number of lines as argument could be useful.

base64 /dev/urandom | awk '{print(0==NR%10)?"":$1}' | sed 's/[^[:alpha:]]/ /g' | head -$1 | awk '{ print NR,$0 }'

lipsum 100 > output_file

  • (1) Your awk command discards every tenth line.  It doesn’t matter for random text, but for less trivial applications you might want to use awk '{print}0==NR%10{print""}' to add a blank line after every tenth line. (2) Yes, awk '{ print NR,$0 }' will print line numbers, but note that there are other tools that are specifically designed to do that (like nl and cat -n). – G-Man Apr 23 at 3:53
  • Thanks @G-Man. (1) For less trivial applications you might consider base64 /dev/urandom | sed '{0~10 s/^.*//;0~10!s/[^A-z]/ /g;50q0}' but this one seems less clear to me. (2) Note that in this case, nl and cat -n do not give the same line-numbering. – ninfito Apr 23 at 6:40

While not technically Lorem Ipsum or a local binary, there is an API on Metaphorpsum which can output similar text but in English. I call it with curl like so:

  • curl http://metaphorpsum.com/sentences/3
  • curl http://metaphorpsum.com/paragraphs/20

Better still, you can define the API call as a function in your bash profile or scripts like this:

loremipsum () {
if [ "${1}" = "" ] || [ "${2}" = "" ]; then
echo "Usage: loremipsum [paragraphs, sentences] [integer]"
curl -s http://metaphorpsum.com/"${1}"/"${2}" && printf "\n"

You can then use it in a very similar way to your example:
loremipsum paragraphs 10 >> file1.txt


Found two other python libs to be used


I made a simple offline solution by means of one of the many lorem ipsum generators on the web. Store a moderate amount of text -- say 20 paragraphs -- in a file, and make the following script executable:

file=$HOME/lib/text/lorem_ipsum && cat $file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.