Sponsored Content
Top Forums Shell Programming and Scripting Pick random file from ls command. Post 302392413 by elbombillo on Thursday 4th of February 2010 10:31:05 AM
Old 02-04-2010
Pick random file from ls command.

Lets say I want to pick a random file when I do an "ls" command. I don't have set number of files in each directory.

Code:
ls | head -1

This gives me the first one in each directory, is there a way to do the same but pick a random one.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How does mutt command pick senders Details

Hi All, We use mutt in one of our scripts to send files as a part of a batch job . The command works nicely but i want to know from where does mutt pick the sender details. As the sender id is different if i use mutt and Mail utility. I can not change the command to mail as it is a part of the... (1 Reply)
Discussion started by: amit1_x
1 Replies

2. Shell Programming and Scripting

Random command

I am trying to select one random word from a file, any ideas on how to do this as i have only manged to generete the random number? (1 Reply)
Discussion started by: melaz
1 Replies

3. Shell Programming and Scripting

How to Pick Random records from a large file

Hi, I have a huge file say with 2000000 records. The file has 42 fields. I would like to pick randomly 1000 records from this huge file. Can anyone help me how to do this? (1 Reply)
Discussion started by: ajithshankar@ho
1 Replies

4. Shell Programming and Scripting

Pick one file from each subdirectory

Hi, I have a problem I am trying to solve with bash. I need to search in a file system (data base) with hundreds of directories and thousands of subdirectories and millions of files. The files have a specific format with a header that gives the properties. Directories are organized so... (1 Reply)
Discussion started by: majest
1 Replies

5. UNIX for Dummies Questions & Answers

Need command to pick the latest file

Hi In my script i am trying to access mainframe server using FTP, in the server i have filee with the timestamp.I need to get the file with the latest timestamp among them . The server has the below files / ftp> cd /outbox 250 CWD command successful ftp> ls 200 PORT command successful... (4 Replies)
Discussion started by: laxmi131
4 Replies

6. 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

7. Shell Programming and Scripting

Code to pick all files from a directory and send it to a command

(4 Replies)
Discussion started by: rossi
4 Replies

8. Shell Programming and Scripting

[Solved] Help with random pick 1000 number from range 1 to 150000

Hi, Do anybody knows how to use awk or any command to random print out 1000 number which start from range 1 to 150000? I know that "rand" in awk can do similar random selection. But I have no idea how to write a code that can random pick 1000 number from range 1 to 150000 :confused: ... (1 Reply)
Discussion started by: perl_beginner
1 Replies

9. Shell Programming and Scripting

Pick up files to process using ls command

Hello All, I have a list of files as below --------- FORM_PTIR_9484_ANFDOP_20150716_00263059.DAT FORM_PTIR_9484_TIFDOP_20150716_00263059.DAT FORM_PTIR_9484_EXFDOP_20150716_00263059.DAT FORM_PTIR_9484_ANFDEX_20150716_00263059.DAT FORM_PTIR_9484_ANFDCA_20150716_00263059.DAT and so on....... (4 Replies)
Discussion started by: rac
4 Replies
Tspi_TPM_GetRandom(3)					     Library Functions Manual					     Tspi_TPM_GetRandom(3)

						     TCG Software Stack Developer's Reference

NAME
Tspi_TPM_GetRandom - generate a random number on the TPM SYNOPSIS
#include <tss/platform.h> #include <tss/tcpa_defines.h> #include <tss/tcpa_typedef.h> #include <tss/tcpa_struct.h> #include <tss/tss_typedef.h> #include <tss/tss_structs.h> #include <tss/tspi.h> TSS_RESULT Tspi_TPM_GetRandom(TSS_HTPM hTPM, UINT32 size, BYTE** random); DESCRIPTION
Tspi_TPM_GetRandom gets a good random number for the purpose of generating symmetric keys, nonces, or seeding a random number generator. PARAMETERS
hTPM The hTPM parameter is used to specify the handle of the TPM object. The command to get the TPM to test itself will be sent here. size The size parameter is the number of random bytes requested. random The random parameter is a pointer to memory containing the random data. This is where the generated number goes. Because this internally allocates memory, Tspi_Context_FreeMemory should also be used. RETURN CODES
Tspi_TPM_GetRandom returns TSS_SUCCESS on success, otherwise one of the following values is returned: TSS_E_INVALID_HANDLE hTPM is not a valid handle. TSS_E_INTERNAL_ERROR An internal SW error has been detected. TSS_E_BAD_PARAMETER One or more parameters is bad. CONFORMING TO
Tspi_TPM_GetRandom conforms to the Trusted Computing Group Software Specification version 1.1 Golden SEE ALSO
Tspi_Context_FreeMemory(3). TSS 1.1 2004-05-25 Tspi_TPM_GetRandom(3)
All times are GMT -4. The time now is 06:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy