Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Retrieving random numbers out of a text file Post 302267503 by benefactr on Friday 12th of December 2008 01:46:50 PM
Old 12-12-2008
Try this on when catting your tmpfile. This would only work if there is spaces before the numbers in your tmpfile, as it looks like there are.

Code:
cat tempIP | tr -s " " | cut -d " " -f2

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sed - Replacing numbers w/asteriks in random location in a file

I have a file which contains lots of text (comment field). I would like to parse through the comment field which can be up to 255 characters long and look for anything that seems to resemble, say, a credit card number or customer account number, etc. and replace the numbers with asteriks (*). ... (9 Replies)
Discussion started by: giannicello
9 Replies

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

3. Shell Programming and Scripting

random select text file ranamed

i want to need script.. source.txt /home/user1/public_html/test3 /home/user90/public_html/test9 . . . /home/user650/public_html/test000 read source.txt and cd /home/user**/public_html/*** and there is 1.txt, 2txt ~~25.txt and select 6 text files randomly among the... (4 Replies)
Discussion started by: topic32428285
4 Replies

4. Shell Programming and Scripting

Random word from a flat text file

Hello, I need to take a random word from a flat text file with words in it seperated by spaces. The code I am using, always gives me the first word. Can anyone please shed some light on this. Here's my code. Thanks echo table roof ceiling jar computer monitor keyboard carpet >... (5 Replies)
Discussion started by: Freakhan
5 Replies

5. Shell Programming and Scripting

Read random line from a text file

I have a text file with hundreds of lines, i wish to run a script and reads a random line to pass it to another command line such as: for line in `cat file |grep random line`; do echo $line |mail my@example.com ; done thank you (6 Replies)
Discussion started by: Bashar
6 Replies

6. Shell Programming and Scripting

Help in retrieving the ending line numbers of the functions

Hi! I've a C file which consist of many function definitions with numbers at the beginning as shown below.. 10 void search() 11 { 12 /*body 14 * 15 * 17 * 18 * 40 * 42 * 60 } 90 void func_name() 95 { 99 /*body 100 * 105 * 111 * (7 Replies)
Discussion started by: abk07
7 Replies

7. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

8. Shell Programming and Scripting

Retrieving values from a line in text file

Hi, I am new to Unix/ksh script and will like to check how do I retrieve just the count of '258' in the last line in a text file ? There will be this "TRL" appended with number of count at the last line in a text file . TRL0000000258 var=`grep 'TRL' $HOME/folder/test.txt | wc -l` ... (12 Replies)
Discussion started by: snowfrost
12 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
tmpfile(3C)						   Standard C Library Functions 					       tmpfile(3C)

NAME
tmpfile - create a temporary file SYNOPSIS
#include <stdio.h> FILE *tmpfile(void); DESCRIPTION
The tmpfile() function creates a temporary file and opens a corresponding stream. The file will automatically be deleted when all refer- ences to the file are closed. The file is opened as in fopen(3C) for update (w+). The largest value that can be represented correctly in an object of type off_t will be established as the offset maximum in the open file description. RETURN VALUES
Upon successful completion, tmpfile() returns a pointer to the stream of the file that is created. Otherwise, it returns a null pointer and sets errno to indicate the error. ERRORS
The tmpfile() function will fail if: EINTR A signal was caught during the execution of tmpfile(). EMFILE There are OPEN_MAX file descriptors currently open in the calling process. ENFILE The maximum allowable number of files is currently open in the system. ENOSPC The directory or file system which would contain the new file cannot be expanded. The tmpfile() function may fail if: EMFILE There are FOPEN_MAX streams currently open in the calling process. ENOMEM Insufficient storage space is available. USAGE
The stream refers to a file which is unlinked. If the process is killed in the period between file creation and unlinking, a permanent file may be left behind. The tmpfile() function has a transitional interface for 64-bit file offsets. See lf64(5). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
unlink(2), fopen(3C), mkstemp(3C), mktemp(3C), tmpnam(3C), lf64(5), standards(5) SunOS 5.11 4 Aug 2003 tmpfile(3C)
All times are GMT -4. The time now is 02:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy