hello
i just seeking for a simple way to make a shuffle by block of words in a line. no matter shell (sh/bash) or perl
should be like this:
the message (which is line of some file) splits to packs (packs are random 5-10 words in each) then making a new line inserting those packs in a random order. then goes to next line in file
simple as that
example:
input file is full of lines such like this:
the message (which is line of some file) splits to packs (packs are random 5-10 words in each) then making a new line inserting those packs in a random order. then goes to next line in file
output file should be:
making a new line inserting those order. then goes to next line in file splits to packs (packs are random the message (which is line of some file) 5-10 words in each) then packs in a random
then next line in those file is another line of words
---------- Post updated at 10:40 AM ---------- Previous update was at 10:38 AM ----------
it should be pretty easy on perl with hes regexp and arrays
but should be not hard with awk too. maybe 1 line even
atm i'm trying to make this script on shell by making array and then take 5-10 random array elements and make a new message but this will be alot of code
yeah, working like that
is it works only with command line?
cuz i dont know how to get line from file and make it vars $1 $2 etc which is command line vars only
is there a way to make it work with reading lines from files?
P.S. what exactly means
set -f
set -- $1
set +f
?
why used # in a:
while [ ${#pack[@]} -gt 0 ]
i know $(pack[@]} shows whole array but u using random on it when it contain words not numbers so u need to use # or why? looks like it works like $# means gives u only number of arrays
and why pack+ goes with +
---------- Post updated at 09:01 PM ---------- Previous update was at 08:55 PM ----------
oh i got it
cat somefile |
{
while read linecho; do
randomize "$linecho"; echo ""
done
}