Sponsored Content
Full Discussion: Generating line number
Top Forums UNIX for Dummies Questions & Answers Generating line number Post 302213019 by Amey Joshi on Wednesday 9th of July 2008 03:34:56 AM
Old 07-09-2008
Quote:
Originally Posted by nua7
Code:
cat -n file-name > new_file

Thanks!Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generating random number within a specific range (0.5-1.5)

Hello, need a way to generate numbers within 0.5-1.5 range Has to be totally random: 0.6 1.1 0.8 1.5 0.6 and so on.... How to? (10 Replies)
Discussion started by: TehOne
10 Replies

2. Programming

generating 16 digit random number in C

Hi, How can we generate 16 digit random nos in C. (10 Replies)
Discussion started by: ajaysahoo
10 Replies

3. Programming

C Help; generating a random number.

Im new to C, and Im having a hard time getting a random number. In bash, I would do something similar to the following to get a random number; #!/bin/bash seed1=$RANDOM seed2=$RANDOM seed3=$RANDOM SEED=`expr $seed1 * $seed2 / $seed3` echo ${SEED%.*} Now, in online examples... (4 Replies)
Discussion started by: trey85stang
4 Replies

4. UNIX for Dummies Questions & Answers

How to read contents of a file from a given line number upto line number again specified by user

Hello Everyone. I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below: if ; then if ; then tail +$1 $3 | head -n $2 else ... (5 Replies)
Discussion started by: grc
5 Replies

5. Programming

Generating Random Number in Child Process using Fork

Hello All, I am stuck up in a program where the rand functions ends up giving all the same integers. Tried sleep, but the numbers turned out to be same... Can anyone help me out how to fix this issue ? I have called the srand once in the program, but I feel like when I call fork the child process... (5 Replies)
Discussion started by: manisum
5 Replies

6. Shell Programming and Scripting

Help with ahem Prime number Generating Script

Can anybody tell me why the second part of this script (Sieve of Eratosthenes) isn't working properly. This isnt coursework or homework just private studies ( Yes Project Euler began it ) I know there are easier ways of doing this too but I want to do it this way.:p Iam using Cygwin on Vista... (3 Replies)
Discussion started by: drewann
3 Replies

7. Shell Programming and Scripting

Generating graphs for many number of files

Hi, I have a series of data files for which I wish to plot using "splot". Say, the files names are like: 950_data,951_data,952_data,......1000_data. For one file , say to plot 950_data, i write following lines into a single file and load it in the gnuplot as : gnuplot> load 'plot' ... (6 Replies)
Discussion started by: begin_shell
6 Replies

8. Shell Programming and Scripting

Generating Random Number in certain range

Hi there I am trying to generate a random number between 40 and 70 using the shell here is my code so far and it keeps going above 70. all help much appreciated! comp=$(( RANDOM%70+40 )) echo $comp (4 Replies)
Discussion started by: faintingquiche
4 Replies

9. Shell Programming and Scripting

Random number generating script?

Having a hard time with this. Very new to scripting and linux. Spent all sunday trying to do this. Appreciate some help and maybe help breaking down what the syntax does. Create a Bash program. It should have the following properties • Creates a secret number between 1 and 100 i. The... (3 Replies)
Discussion started by: LINUXnoob15
3 Replies

10. Shell Programming and Scripting

Generating a POSIX random number?

Hi Guys and gals... As you know I am getting to grips with POSIX and hit this stumbling block. Generating two random numbers 0 to 255 POSIXly. Speed in not important hence the 'sleep 1' command. I have done a demo that works, but it sure is ugly! Is there a better way? #!/bin/sh # Random... (12 Replies)
Discussion started by: wisecracker
12 Replies
GOPHER_PARSEDIR(3)							 1							GOPHER_PARSEDIR(3)

gopher_parsedir - Translate a gopher formatted directory entry into an associative array.

SYNOPSIS
array gopher_parsedir (string $dirent) DESCRIPTION
gopher_parsedir(3) parses a gopher formatted directory entry into an associative array. While gopher returns text/plain documents for actual document requests. A request to a directory (such as /) will return specially encoded series of lines with each line being one directory entry or information line. PARAMETERS
o $dirent - The directory entry. RETURN VALUES
Returns an associative array whose components are: o type - One of the GOPHER_XXX constants. o title - The name of the resource. o path - The path of the resource. o host - The domain name of the host that has this document (or directory). o port - The port at which to connect on host. Upon failure, the additional data entry of the returned array will hold the parsed line. EXAMPLES
Example #1 Hypothetical output from gopher://gopher.example.com/ 0All about my gopher site. /allabout.txt gopher.example.com 70 9A picture of my cat. /pics/cat.png gopher.example.com 70 1A collection of my writings. /stories gopher.example.com 70 hThe HTTP version of this site. URL:http://www.example.com gopher.example.com 70 1Mirror of this site in Spain. / gopher.ejemplo.co.es 70 iWelcome to my gopher site. error.host 1 iPlease select one of the options above error.host 1 iSend complaints to /dev/null error.host 1 iLong live gopher! error.host 1 In the example above, the root directory at gopher.example.com knows about one DOCUMENT identified by 0 located at gopher://gopher.exam- ple.com:70/allabout.txt. It also knows about two other directory (which have their own listing files) at gopher://gopher.exmaple.com:70/stories and at gopher://gopher.ejemplo.co.es:70/. In addition there is a binary file, a link to an HTTP url, and several informative lines. By passing each line of the directory listing into gopher_parsedir(3), an associative array is formed containing a parsed out version of the data. Example #2 Using gopher_parsedir(3) <?php $directory = file("gopher://gopher.example.com"); foreach($directory as $dirent) { print_r(gopher_parsedir($dirent)); } ?> The above example will output: Array ( [type] => 0 [title] => All about my gopher site. [path] => /allabout.txt [host] => gopher.example.com [port] => 70 ) Array ( [type] => 9 [title] => A picture of my cat. [path] => /pics/cat.png [host] => gopher.example.com [port] => 70 ) Array ( [type] => 1 [title] => A collection of my writings. [path] => /stories [host] => gopher.example.com [port] => 70 ) Array ( [type] => 254 [title] => The HTTP version of this site. [path] => URL:http://www.example.com [host] => gopher.example.com [port] => 70 ) Array ( [type] => 1 [title] => Mirror of this site in Spain. [path] => / [host] => gopher.ejemplo.co.es [port] => 70 ) Array ( [type] => 255 [title] => Welcome to my gopher site. [path] => [host] => error.host [port] => 1 ) Array ( [type] => 255 [title] => Please select one of the options above. [path] => [host] => error.host [port] => 1 ) Array ( [type] => 255 [title] => Send complaints to /dev/null [path] => [host] => error.host [port] => 1 ) Array ( [type] => 255 [title] => Long live gopher! [path] => [host] => error.host [port] => 1 ) PHP Documentation Group GOPHER_PARSEDIR(3)
All times are GMT -4. The time now is 02:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy