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(3)						     Linux Programmer's Manual							TMPFILE(3)

NAME
tmpfile - create a temporary file SYNOPSIS
#include <stdio.h> FILE *tmpfile(void); DESCRIPTION
The tmpfile() function opens a unique temporary file in binary read/write (w+b) mode. The file will be automatically deleted when it is closed or the program terminates. RETURN VALUE
The tmpfile() function returns a stream descriptor, or NULL if a unique filename cannot be generated or the unique file cannot be opened. In the latter case, errno is set to indicate the error. ERRORS
EACCES Search permission denied for directory in file's path prefix. EEXIST Unable to generate a unique filename. EINTR The call was interrupted by a signal; see signal(7). EMFILE The per-process limit on the number of open file descriptors has been reached. ENFILE The system-wide limit on the total number of open files has been reached. ENOSPC There was no room in the directory to add the new filename. EROFS Read-only filesystem. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +----------+---------------+---------+ |Interface | Attribute | Value | +----------+---------------+---------+ |tmpfile() | Thread safety | MT-Safe | +----------+---------------+---------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD, SUSv2. NOTES
POSIX.1-2001 specifies: an error message may be written to stdout if the stream cannot be opened. The standard does not specify the directory that tmpfile() will use. Glibc will try the path prefix P_tmpdir defined in <stdio.h>, and if that fails the directory /tmp. SEE ALSO
exit(3), mkstemp(3), mktemp(3), tempnam(3), tmpnam(3) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. 2016-03-15 TMPFILE(3)
All times are GMT -4. The time now is 05:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy