Sponsored Content
Full Discussion: random words
Top Forums UNIX for Dummies Questions & Answers random words Post 302500241 by kurumi on Monday 28th of February 2011 03:21:01 AM
Old 02-28-2011
Quote:
Originally Posted by eldeingles

kurumi: the best! nailed it! even though i tried to apply it to a list of words separated by a tab (\t) but didn't work.

My other job was to shuffle the words in a tab-separated list like this:

go went gone
sleep slept slept
...

to get something like:

went go gone
slept slept sleep
it should work.

Code:
$ od -c file #notice the tabs
0000000   g   o  \t   w   e   n   t  \t   g   o   n   e  \n   s   l   e
0000020   e   p  \t   s   l   e   p   t  \t   s   l   e   p   t  \n
0000037

$ ruby -ne 'BEGIN{srand};puts $_.split.shuffle.join(" ")' file
went gone go
slept sleep slept

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to find out words, replace them and count words

hello, i 'd like your help about a bash script which: 1. finds inside the html file (it is attached with my post) the code number of the Latest Stable Kernel, 2.finds the link which leads to the download location of the Latest Stable Kernel version, (the right link should lead to the file... (3 Replies)
Discussion started by: alex83
3 Replies

2. Ubuntu

expect script for random password and random commands

Hi I am new to expect. Please if any one can help on my issue its really appreciable. here is my issue: I want expect script for random passwords and random commands generation. please can anyone help me? Many Thanks in advance (0 Replies)
Discussion started by: vanid
0 Replies

3. Shell Programming and Scripting

Need to generate a file with random data. /dev/[u]random doesn't exist.

Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom. I create a named pipe then: dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024 but when I cat a file to the fifo that's 1024 random bytes: cat randomfile.txt >... (7 Replies)
Discussion started by: Devyn
7 Replies

4. Shell Programming and Scripting

How count the number of two words associated with the two words occurring in the file?

Hi , I need to count the number of errors associated with the two words occurring in the file. It's about counting the occurrences of the word "error" for where is the word "index.js". As such the command should look like. Please kindly help. I was trying: grep "error" log.txt | wc -l (1 Reply)
Discussion started by: jmarx
1 Replies

5. Shell Programming and Scripting

Gawk gensub, match capital words and lowercase words

Hi I have strings like these : Vengeance mitt Men Vengeance gloves Women Quatro Windstopper Etip gloves Quatro Windstopper Etip gloves Girls Thermobite hooded jacket Thermobite Triclimate snow jacket Boys Thermobite Triclimate snow jacket and I would like to get the lower case words at... (2 Replies)
Discussion started by: louisJ
2 Replies

6. UNIX for Dummies Questions & Answers

Replace the words in the file to the words that user type?

Hello, I would like to change my setting in a file to the setting that user input. For example, by default it is ONBOOT=ON When user key in "YES", it would be ONBOOT=YES -------------- This code only adds in the entire user input, but didn't replace it. How do i go about... (5 Replies)
Discussion started by: malfolozy
5 Replies

7. UNIX for Dummies Questions & Answers

Deleting words between every appearance of two words

Hi there, newbie there. I've been browsing the forums hoping to find a solution that answers a problem similar to what I need, but haven't had much luck. Any help would be greatly appreciated. Thanks! I need to delete a bunch of text between every appearance of two words in a really large file... (3 Replies)
Discussion started by: lendl
3 Replies

8. Shell Programming and Scripting

Search words in any quote position and then change the words

hi, i need to replace all words in any quote position and then need to change the words inside the file thousand of raw. textfile data : "Ninguno","Confirma","JuicioABC" "JuicioCOMP","Recurso","JuicioABC" "JuicioDELL","Nulidad","Nosino" "Solidade","JuicioEUR","Segundo" need... (1 Reply)
Discussion started by: benjietambling
1 Replies

9. Shell Programming and Scripting

Replace particular words in file based on if finds another words in that line

Hi All, I need one help to replace particular words in file based on if finds another words in that file . i.e. my self is peter@king. i am staying at north sydney. we all are peter@king. How to replace peter to sham if it finds @king in any line of that file. Please help me... (8 Replies)
Discussion started by: Rajib Podder
8 Replies

10. UNIX for Beginners Questions & Answers

Create 'n' number random pairwise combination of words

File 1 contains the list of words that needed to be randomly paired: Tiger Cat Fish Frog Dog Mouse Elephant Monkey File 2 contains the pairs that should not be used (in any solution) during random pairing. Elephant-Dog Cat-Fish Monkey-Frog Dog-Elephant, Fish-Cat, Frog-Monkey... (1 Reply)
Discussion started by: sammy777888
1 Replies
NANOSLEEP(2)						      BSD System Calls Manual						      NANOSLEEP(2)

NAME
nanosleep -- suspend thread execution for an interval measured in nanoseconds LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <time.h> int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); DESCRIPTION
The nanosleep() function causes the calling thread to sleep for the amount of time specified in rqtp (the actual time slept may be longer, due to system latencies and possible limitations in the timer resolution of the hardware). An unmasked signal will cause nanosleep() to ter- minate the sleep early, regardless of the SA_RESTART value on the interrupting signal. RETURN VALUES
If nanosleep() returns because the requested time has elapsed, the value returned will be zero. If nanosleep() returns due to the delivery of a signal, the value returned will be the -1, and the global variable errno will be set to indi- cate the interruption. If rmtp is non-NULL, the timespec structure it references is updated to contain the unslept amount (the request time minus the time actually slept). ERRORS
The nanosleep() call fails if: [EINTR] nanosleep() was interrupted by the delivery of a signal. [EINVAL] rqtp specified a nanosecond value less than zero or greater than or equal to 1000 million. SEE ALSO
sigsuspend(2), sleep(3) STANDARDS
The nanosleep() function conforms to IEEE Std 1003.1b-1993 (``POSIX.1''). BSD
April 17, 1997 BSD
All times are GMT -4. The time now is 08:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy