Create a file with aleatory text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create a file with aleatory text
# 1  
Old 09-08-2008
Create a file with aleatory text

Can someone guide me on how to write a small script to create a text file with non-sense text, i.e. lorem ipsum... I would like it with about 5 paragraphs but I have no idea on how to perfrom that. Any help will be much appreciated.

Thanks,
# 2  
Old 09-08-2008
Hammer randomly on the keyboard for 30 seconds?
# 3  
Old 09-08-2008
Lorem Ipsum - All the facts - Lipsum generator has links to Lorem Ipsum generators in several programming languages.
# 4  
Old 09-08-2008
Hi.

I don't have any small scripts, but you can combine several sources, perhaps with :
Quote:
Description: Automated Password Generator - Standalone version
APG (Automated Password Generator) is the tool set for random
password generation. It generates some random words of required type
and prints them to standard output.

APG (Automated Pasword Generator)

-- excerpt from GNU/Debian apt-cache show apg
like this:
Code:
#!/bin/bash -

# @(#) s1       Demonstrate methods to generate random text.

echo
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1)
set -o nounset

echo
echo " Results of apg:"
apg -n 6 -M l -m 6 -x 10

echo
echo " Results of gpp:"
gpp -n 6

echo
echo " Sample of dictionary:"
sample -6 ~/etc/data/dict/words

echo
cat <<EOF

# Analyze a piece of text; one such (Chapter 1 of Moby Dick) had
# ratios of the following sentence terminators:
#
#       ".": 76%
#       "?": 17%
#       "!":  7%
#
# Similarly for length of sentences.
EOF

echo
echo " Sample of mixture:"
sentence 10 |
fmt

exit 0

Producing -- one instance:
Code:
% ./s1

(Versions displayed with local utility "version")
Linux 2.6.11-x1
GNU bash 2.05b.0

 Results of apg:
nubchaydna
gahognes
jonhaphous
tratharu
dikopemtyi
oorbyadeb

 Results of gpp:
ork
ulvind
indalvidst
ilk
spotchict
ifadgebs

 Sample of dictionary:
athletic
combinatorial
electroencephalogram
exhortation
junk
procedural


# Analyze a piece of text; one such (Chapter 1 of Moby Dick) had
# ratios of the following sentence terminators:
#
#       ".": 76%
#       "?": 17%
#       "!":  7%
#
# Similarly for length of sentences.

 Sample of mixture:
Opthalmic toenail clown lockstep NASA Moulton dowry Dana except.

Shall Frenchmen Mekong pupil buckwheat tonsil preeminent scopic Dirac
impost draftsmen.  Comatose insolvent bound crumy, smibsatch shutchals
Mona fife secretion?  Rail Paterson weird Gustavus aggressive successor
prong.  Kombu brutch friable comprehend pallid scandium?

Deane Leviticus pathway flack influential amphibian crochet.
Smot edgorchifte adrenal rhombus shrift shodsodgunth semaphore Elton.
Dorcas epigenetic firm olchentems clothesman brainchildren legitimate
rather Windsor srakajy struds?  Chiefdom pothole pax adolescent acceptant
irreclaimable magnetron!  Calvert Sophia collegiate clapboard Toby
empumpe figural could rouge bolt.

cheers, drl
# 5  
Old 09-08-2008
# 6  
Old 09-08-2008
Hi.

This may involve more work than you wanted to do, but there is a old perl code http://www.cpan.org/scripts/nutshell/ch6/travesty that scrambles text. The book noted below has a short chunk of perl code that can produce random-looking text from a known text using a Markov chain algorithm. For example, using the former:
Code:
#!/bin/bash -

# @(#) s2       Demonstrate scrambling text.

echo
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1)
set -o nounset
echo

FILE=${1-m1}

echo " Data file $FILE:"
tail +4 $FILE |
edges

echo
echo " Results:"
tail +4 $FILE |
travesty |
fmt |
edges

exit 0

Code:
% ./s2

(Versions displayed with local utility "version")
Linux 2.6.11-x1
GNU bash 2.05b.0

 Data file m1:
     1  Call me Ishmael.  Some years ago--never mind how long precisely
     2  --having little or no money in my purse, and nothing particular
     3  to interest me on shore, I thought I would sail about a little
     4  and see the watery part of the world.  It is a way I have of
     5  driving off the spleen, and regulating the circulation.
   ...
   199  flood-gates of the wonder-world swung open, and in the wild
   200  conceits that swayed me to my purpose, two and two there floated
   201  into my inmost soul, endless processions of the whale, and, mid
   202  most of them all, one grand hooded phantom, like a snow hill in
   203  the air.

 Results:
     1   in monied me Call to of crowds same rub or Providence awe them
     2  much the same way do the commonalty lead their leaders in many other
     3  things, at the same way do the commonalty lead their leaders in many
     4  other things, at the same way do the commonalty lead their leaders in many
     5  other things, at the same feelings towards the ocean with me.  There now
   ...
   334  could not grasp the tormenting, mild image he saw in the habit of going
   335  to sea as soon as I can. This is my substitute for pistol and ball. With
   336  a philosophical flourish Cato throws himself upon his sword; I quietly
   337  take to the ship. There is nothing surprising in this. If they but knew
   338  it, almost all men in their hill-side blue. But though the picture

cheers, drl
Quote:
Title: The Practice of Programming
Author: Brian W. Kernighan, Rob Pike
Date: February 14, 1999
Publisher: Addison-Wesley Professional
ISBN: 0-201-61586-X
Pages: 288
Categories: programming, language, software engineering
Comments: 4 stars ( 49 reviews Amazon 2008.02 )
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create a text file and a pdf file from Linux command results.

Hello. The task : Using multiple commands like : gdisk -l $SOME_DISK >> $SOME_FILEI generate some text file. For readiness I must insert page break. When the program is finished I want to convert the final text file to a pdf file. When finished, I got two files : One text file and One pdf... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Splitting a text file into smaller files with awk, how to create a different name for each new file

Hello, I have some large text files that look like, putrescine Mrv1583 01041713302D 6 5 0 0 0 0 999 V2000 2.0928 -0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 5.6650 0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 3.5217 ... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

3. Shell Programming and Scripting

Create csv from text file

Gents, I am trying to create a csv file using the file attached. I have a problem to get all information required because the rows are not continues. Here is my code till now. awk ' /"ffid"/{if(s){print s;s=$NF}else{s=$NF}} /"LineNumber"/{s=s $NF} /"PointNumber"/{s=s $NF}... (4 Replies)
Discussion started by: jiam912
4 Replies

4. Shell Programming and Scripting

Copy text and create new file

I have a directory with ~500 files that look like below. I need to copy each unique entry up until the second_ only once and put a .txt in place of the _. I am not quite sure how but have the below as a startThank you :). cp -u file1.txt "$(cat output.txt)" file1.txt ... (4 Replies)
Discussion started by: cmccabe
4 Replies

5. Shell Programming and Scripting

Script to create a text file whose content is the text of another files

Hello everyone, I work under Ubuntu 11.10 (c-shell) I need a script to create a new text file whose content is the text of another text files that are in the directory $DIRMAIL at this moment. I will show you an example: - On the one hand, there is a directory $DIRMAIL where there are... (1 Reply)
Discussion started by: tenteyu
1 Replies

6. Red Hat

create pdf of text file help

Can someone please tell me why this is not working? I have created numerous pdf's from text files by following these instructions and this time it is not working. Convert jpeg files to PDF under Linux | bitPrison.net convert /home/liveuser/Documents/hw7 /home/liveuser/Documents/hw7.pdf... (5 Replies)
Discussion started by: cokedude
5 Replies

7. UNIX for Dummies Questions & Answers

Script to create text file.

Hi all Below this is my script..I want to write the command to create a text file in my script below. If anyone know how to do...show me the result.I also want to do this script run automatically without type in terminal. Thanks. #!/usr/bin/sh... (6 Replies)
Discussion started by: mastercar
6 Replies

8. Shell Programming and Scripting

Create multiple text file from a single text file on AIX

Hi I need to create multiple text files from onc text file on AIX. The data of text files is as below: ********************************************** ********************************************** DBVERIFY: Release 10.2.0.4.0 - Production on Tue Nov 10 13:45:42 2009 Copyright (c) 1982,... (11 Replies)
Discussion started by: lodhi1978
11 Replies

9. Shell Programming and Scripting

Create a formated text file

Hi, I have written a BASH shell script (included below) which will allow me to monitor my blood pressure. The script computes the mean of 5 user input systolic, diastolic, and heart rate values. I would like the script to then append these three values to their respective columns in a text... (5 Replies)
Discussion started by: msb65
5 Replies

10. UNIX for Dummies Questions & Answers

create a text file in a script

Hi, i want to create a text file (init${x}.ora) and write information to it via a korn shell script. Is it right to do it as shown below (the file doesnt exist yet)? x=$1 file="$ORC/dbs/init${x}.ora" echo "info here..." >> $file will this file get created? (2 Replies)
Discussion started by: n8575
2 Replies
Login or Register to Ask a Question