Sponsored Content
Full Discussion: generate level numbers
Top Forums Shell Programming and Scripting generate level numbers Post 302137103 by Perderabo on Saturday 22nd of September 2007 05:28:32 AM
Old 09-22-2007
Put the script back the way I wrote it. You cannot introduce random changes to my script and expect it to continue to work. I will test my script, not yours. My script with E in the data:
$ cat datae
A 0
B 0
C 0
D 0
E A
E B
E C
Z H
Z D
F E
G E
H E
I G
$ ./level datae
A 0 1
B 0 1
C 0 1
D 0 1
E A 2
E B 2
E C 2
F E 3
G E 3
H E 3
I G 4
Z D 4
Z H 4
$

And my script with P in the data:
$ cat datap
A 0
B 0
C 0
D 0
P A
P B
P C
Z H
Z D
F P
G P
H P
I G
$ ./level datap
A 0 1
B 0 1
C 0 1
P A 2
P B 2
P C 2
D 0 1
F P 3
G P 3
H P 3
I G 4
Z D 4
Z H 4
$

The only difference is that the "D 0 1" moved below the E/P lines. That is an artifact of tsort, there are several possible ways to order the data and tsort displays one of them. If this bothers you, use a final sort to sort the output.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to generate a series of numbers

Hi All, I have a requirement where in I have an input as follows:- input=1-4,6,8-10,12-15 I need to explode this range into an output file as follows:- 1 2 3 4 6 8 9 10 12 13 14 15 My input may vary like 1,5-9,11-13,15-17....... (3 Replies)
Discussion started by: rony_daniel
3 Replies

2. Shell Programming and Scripting

How to generate 10.000 unique numbers?

hello, does anybody can give me a hint on how to generate a lot of numbers which are not identically via scripting etc? (7 Replies)
Discussion started by: xrays
7 Replies

3. Shell Programming and Scripting

Generate numbers 000 to 999

I have tried to make this script to generate: 000 001 002 ... 997 998 999 i=0 while do if then echo "00"$i else if && then echo "0"$i (5 Replies)
Discussion started by: locoroco
5 Replies

4. Programming

generate array of random numbers

hi guys, I am writing a c program that generates a two dimensional array to make matrix and a vector of random numbers and perform multiplication. I can't figure out whats wrong with my code. It generates a matrix of random numbers but all the numbers in the vector array is same and so is the... (2 Replies)
Discussion started by: saboture88
2 Replies

5. Shell Programming and Scripting

Generate Codes based on start and End values of numbers in a column

Hello All, Could you please help with this. This is what I have: 506234.222 2 506234.222 2 506234.222 2 506234.222 2 508212.200 2 508212.200 2 333456.111 2 333456.111 2 333456.111 2 333456.111 2 But this is what I want: 506234.222 1 506234.222 2 506234.222 2 506234.222 3 (5 Replies)
Discussion started by: canimba
5 Replies

6. Shell Programming and Scripting

Generate 16 digit positive random Numbers

Hi Unix Gurus, I have a requirement to generate positive random 16 and 13 digit numbers. Here is the script I have so far..... number=$RANDOM$RANDOM$RANDOM$RANDOM; let "number %= 10000000000000"; echo $number But sometimes it is generating negative numbers and also 15 digit... (8 Replies)
Discussion started by: scorpioraghu
8 Replies

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

8. Shell Programming and Scripting

Auto generate Line Numbers

How do I generate line numbers in Vi? I have this: ,'04-90020-039N','61423','2GDV00039-0002', SYSDATE); ,'04-90020-040D','61423','2GDV00046-0001', SYSDATE); ,'04-90020-041N','61423','2GDV00038-0002', SYSDATE); ,'04-90020-043D','61423','2GDV00047-0001', SYSDATE);... (3 Replies)
Discussion started by: djehresmann
3 Replies

9. Shell Programming and Scripting

Need advise to generate 10 character numbers example 0000000000 - 9999999999

Hi all, i need advise from all experts here. when i use command below to print number in 10 character printf "%010d\n" {0..999} it will give me output nicely starts from 0000000000 untillllllllllll 0000000994 0000000995 0000000996 0000000997 0000000998 0000000999 However. when i... (6 Replies)
Discussion started by: jason6247
6 Replies

10. Shell Programming and Scripting

Script to generate sequence of numbers

I need awk script to generate part number sequencing based on data in multiple columns like below Input File --------- Col A|Col B|Col C| 1|a|x| 2|b|y| |c|z| | |m| | |n| And out put should be like 1ax 1ay 1az 1am 1an 1bx 1by (6 Replies)
Discussion started by: aramacha
6 Replies
tsort(1)						      General Commands Manual							  tsort(1)

NAME
tsort - Sorts an unordered list of ordered pairs (topological sort) SYNOPSIS
tsort [file] STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: tsort: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
None OPERANDS
Pathname of a test file to be ordered. If no file operand is specified, tsort reads standard input. DESCRIPTION
The tsort command reads from file or standard input an unordered list of ordered pairs, builds an ordered list, and writes it to standard output. [Tru64 UNIX] For creating a subroutine library, do not use tsort; use the following command in its place: % ar -ts file.a The input file should contain pairs of nonempty strings separated by spaces. Pairs of different items indicate a relative order. Pairs of identical items indicate presence, but no relative order. [Tru64 UNIX] You can use tsort to sort the output of the lorder command. [Tru64 UNIX] If file contains an odd number of fields, tsort writes the error message: tsort: Specify an even number of data fields. NOTES
The LC_COLLATE environment variable does not affect the actions of tsort. EXIT STATUS
The following exit values are returned: Successful completion. An error occurred. EXAMPLES
To create a subroutine library, enter: lorder charin.o scanfld.o scan.o scanln.o | tsort | xargs ar qv libsubs.a (Enter the command entirely on one line, not on two lines as shown above.) This creates a subroutine library named libsubs.a that contains charin.o, scanfld.o, scan.o, and scanln.o. The ordering of the object mod- ules in the library is important. The ld command requires each module to precede all the other modules that it calls or references. The lorder and tsort commands together add the subroutines to the library in the proper order. Suppose that scan.o calls scanfld.o and scanln.o. scanfld.o also calls charin.o. First, the lorder command creates a list of pairs that shows these dependencies: charin.o charin.o scanfld.o scanfld.o scan.o scan.o scanln.o scanln.o scanfld.o charin.o scanln.o charin.o scan.o scanfld.o Next, the | (vertical bar) sends this list to the tsort command, which converts it into the ordering you need: scan.o scanfld.o scanln.o charin.o Note that each module precedes the module it calls. charin.o, which does not call another module, is last. The second | (vertical bar) then sends this list to xargs, which constructs and runs the following ar command: ar qv libsubs.a scan.o scanfld.o scanln.o charin.o This ar command creates the properly ordered library. ENVIRONMENT VARIABLES
The following environment variables affect the execution of tsort: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: ar(1), lorder(1), xargs(1) Standards: standards(5) tsort(1)
All times are GMT -4. The time now is 02:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy