Sponsored Content
Top Forums UNIX for Advanced & Expert Users UNIX script for making random numbers without repetition Post 302849677 by sajmar on Monday 2nd of September 2013 10:33:20 PM
Old 09-02-2013
Quote:
Originally Posted by Chubler_XL
Yes, if you just have spaces (or tabs) between the values then remove the -F',' part.
I think my question was not very clear. I have a file which has one column with 7200 line and want to select 1440 lines ( %20 of the line) randomly without the duplication number between the 1440 numbers.
The command did not give me what do I want.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Random numbers without repetition

Is anyone know some scripts to generate random number without repetition using bash; for example generate 10 different random numbers. Thanks (8 Replies)
Discussion started by: asal_email
8 Replies

2. Programming

How to set constrain on random numbers in c

Hi, I am currently trying to generate multiple random numbers in C for different variable:- die1=1+(rand()%5); die2=1+(rand()%5); die3=1+(rand()%5); die4=1+(rand()%5); But I need to contrain the total of die1, die2,die3 and die4 to be 5 as well. If i insert die1+die2+die3+die4=5, i do... (6 Replies)
Discussion started by: ahjiefreak
6 Replies

3. UNIX for Dummies Questions & Answers

Making UNIX script executable

Hello, I am very new to UNIX and I have been learning about writing scripts and making them executable. I created a script called myscript. It has three lines: #! /bin/sh # This is my first shell script echo friendsjustfriends Now I try to run it using the sh command and it works Next I... (4 Replies)
Discussion started by: rohitx
4 Replies

4. Shell Programming and Scripting

Random numbers from 0 to 1000

Hello All, I want to make a simple script which generate random number from 0 to 1000. and simply display it. Plz HELP!!!!!! Regards, Waqas Ahmed (2 Replies)
Discussion started by: wakhan
2 Replies

5. Shell Programming and Scripting

Random Numbers - Perl

Hi Guys I have a script to find Ranomd numbers. But I want to make the file to produce more random. Could u guys help me plz. In this Script I have the code that generates random in for loop and the range I have specified in my %chromlength input and out put will be like this chrno start end... (3 Replies)
Discussion started by: repinementer
3 Replies

6. Shell Programming and Scripting

Generating random numbers

Hi, I am having trouble with generating random numbers. can this be done with awk? So I have a file that looks like this: 23 30 24 40 26 34 So column1 is start and column2 is end. I want to generate 3 random #'s between start and stop: So the output will look like this: ... (9 Replies)
Discussion started by: phil_heath
9 Replies

7. UNIX for Dummies Questions & Answers

Syntax Help | unix | grep | regular expression | repetition

Hello, This is my first post so, Hello World! Anyways, I'm learning how to use unix and its quickly become apparent that a strong foundation in regular expressions will make things easier. I'm not sure if my syntax is messing things up or my logic is messing things up. ps -e | grep... (4 Replies)
Discussion started by: MykC
4 Replies

8. Shell Programming and Scripting

Generate random numbers in script

i want to generate a random number through a script, and even if anyone reads the script, they wont be able to figure out what the random number is. only the person who setup the script would know it. something like this could work: random the full thread is here: ... (13 Replies)
Discussion started by: SkySmart
13 Replies

9. Homework & Coursework Questions

Random numbers

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! Write a shell script that will take the sum of two random number? Ex: Random n1 +Random n2 = result i tries to write it but i had some dufficulties ... (3 Replies)
Discussion started by: renegade755
3 Replies
pr(1)							      General Commands Manual							     pr(1)

Name
       pr - print files

Syntax
       pr [ options ] [ files ]

Description
       The  command  prints  the  named files on the standard output.  If file is designated by a minus sign (-), or if no files are specified the
       command assumes standard input.	By default, the listing is separated into pages, each headed by the page number, a date and time, and  the
       name of the file.

       By default, columns are of equal width, separated by at least one space.  Lines that do not fit are truncated. However, if the -s option is
       used, lines are not truncated and columns are separated by the separation character.

       If the standard output is associated with a terminal, error messages are withheld until has finished printing.

Options
       The following options can be used singly or in combination:

       -a      Prints multi-column output across the page.

       -b      Prints blank headers.

       -d      Double-spaces the output.

       -eck    Expands input tabs to character positions k+1, 2*k+1, 3*k+1,... n*k+1.  If k is 0 or is omitted, tabs are set at every eighth posi-
	       tion.  Tab characters in the input are expanded into the appropriate number of spaces.  The default for c (any non-digit character)
	       is the tab character; therefore, if c is given, it is treated as the input tab character.

       -f      Uses form-feed character for new pages.	The default is to use a sequence of line-feeds.  The -f option causes the command to pause
	       before beginning the first page if the standard output is associated with a terminal.

       -h      Uses the next argument as the header to be printed instead of the file name.

       -ick    Replaces  white space in output by inserting tabs to character positions k+1, 2*k+1, 3*k+1,...n*k+1.  If k is 0 or is omitted, tabs
	       are set at every eighth position.  The default for c (any non-digit character) is the tab character; therefore, if c is	given,	it
	       is treated as the input tab character.

       +k      Begins printing with page k (default is 1).

       -k      Produces k-column output (default is 1).  The -e and -i options are assumed for multi-column output.

       -lk     Sets the length of a page to k lines.  The default is 66 lines.

       -m      Merges and prints all files simultaneously, one per column (overrides the -k, and -a options).

       -nck    Numbers	lines.	The default for k is 20.  The number occupies the first k+1 character positions of each column of normal output or
	       each line of -m output.	If c, which is any non-digit character is given, it is appended to the line number  to	separate  it  from
	       whatever follows.  The default for c is a tab.

       -ok     Offsets	each line by k character positions (default is 0).  The number of character positions per line is the sum of the width and
	       offset.

       -p      Pauses before beginning each page if the output is directed to a terminal.  The command rings the bell at the terminal and awaits a
	       carriage return.

       -r      Suppresses diagnostic reports on failure to open files.

       -sc     Separates columns by the single character c instead of by the appropriate number of spaces (default for c is a tab).

       -t      Suppresses  the	five-line  identifying header and the five-line trailer normally supplied for each page.  The -t option causes the
	       command to quit printing after the last line of each file without spacing to the end of the page.

       -wk     Sets the width of a line to k character positions.  The default is 72 for equal-width multi-column output; otherwise  there  is	no
	       limit.

Examples
       Print file1 and file2 as a double-spaced, three-column listing with the heading:  file list.
       pr -3dh "file list" file1 file2
       Write file1 on file2, expanding tabs to columns 10, 19, 28, 37,...:
       pr -e9 -t <file1>file2

Files
       /dev/tty* to suspend messages

See Also
       cat(1)

																	     pr(1)
All times are GMT -4. The time now is 03:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy