08-27-2014
@ravinder, the use of an array with one single element and for every line changing it content with random information and reading the file twice is not necessary. Instead of $13 in a you can use $13=="ASD" and then you can leave out the NR==FNR section.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I have a large file 2.6 million records and I am trying to split the file based on last column.
I am doing
awk -F"|" '{ print > $NF }' filename1
After around 1000 splits it gives me a error
awk: can't open file 3332332423
input record number 1068, file filename1
source... (6 Replies)
Discussion started by: s_adu
6 Replies
2. Shell Programming and Scripting
I have a file containing date/time sorted data of the form
...
2009/06/10,20:59:59.950,XAG/USD,Q,1,1115, 14.3025,100,1,1
2009/06/10,20:59:59.950,XAG/USD,Q,1,1116, 14.3026,125,1,1
2009/06/10,20:59:59.950,XAG/USD,R,0,0, , 0,0,0
2009/06/10,20:59:59.950,XAG/USD,R,1,0, 14.1910,100,1,1... (6 Replies)
Discussion started by: asriva
6 Replies
3. Shell Programming and Scripting
Hello,
What's the best way to split a large into multiple files based on the last digit in the first column.
input file:
f
2738483300000x0y03772748378831x1y13478378358383x2y23743878383802x3y33787828282820x4y43748838383881x5y5
Desired Output:
f0
3738483300000x0y03787828282820x4y4
f1... (9 Replies)
Discussion started by: alain.kazan
9 Replies
4. Shell Programming and Scripting
I am unable to spit the file based on the 2nd column passing as a parameter with awk command.
Source file:
“100”,”customer information”,”10000”
“200”,”customer information”,”50000”
“300”,”product information”,”40000”
script: the command is not allowing to pass the parameters with the awk... (7 Replies)
Discussion started by: number10
7 Replies
5. Shell Programming and Scripting
Hi,
I have a fixed width text file without any header row. One of the columns contains a date in YYYYMMDD format.
If the original file contains 3 dates, I want my shell script to split the file into 3 small files with data for each date.
I am a newbie and need help doing this. (14 Replies)
Discussion started by: bhanja_trinanja
14 Replies
6. Shell Programming and Scripting
Hi,
I've one requirement. I have to split one comma delimited file into multiple files based on one of the column values.
How can I achieve this Unix
Here is the sample data. In this case I have split the files based on date column(c4)
Input file
c1,c2,c3,c4,c5... (1 Reply)
Discussion started by: manasvi24
1 Replies
7. Shell Programming and Scripting
Good day all
I need some helps,
say that I have data like below, each field separated by a tab
DATE NAME ADDRESS
15/7/2012 LX a.b.c
15/7/2012 LX1 a.b.c
16/7/2012 AB a.b.c
16/7/2012 AB2 a.b.c
15/7/2012 LX2 a.b.c... (2 Replies)
Discussion started by: alexyyw
2 Replies
8. Shell Programming and Scripting
Hi,
I have a file sample_1.txt (300k rows) which has data like below:
* Also each record is around 64k bytes
11|1|abc|102553|125589|64k bytes of data
10|2|def|123452|123356|......
13|2|geh|144351|121123|...
25|4|fgh|165250|118890|..
14|1|abc|186149|116657|......... (6 Replies)
Discussion started by: sol_nov
6 Replies
9. UNIX for Dummies Questions & Answers
i have file1.txt
asdas|csada|130310|0423|A1|canberra
sdasd|sfdsf|130426|2328|A1|sydney
Expected output : on eaceh third and fourth colum, split into each two characters
asdas|csada|13|03|10|04|23|A1|canberra
sdasd|sfdsf|13|04|26|23|28|A1|sydney (10 Replies)
Discussion started by: radius
10 Replies
10. Shell Programming and Scripting
Hi Team,
I have a requirement in such a way that need to split the file into two based on which column particular value appears.Please find my sample file below.
Lets consider the delimiter of this file as either comma or two colons.(:: and ,). So I need to split the file in such a way that all... (2 Replies)
Discussion started by: ginrkf
2 Replies
LEARN ABOUT ULTRIX
initstate
random(3) Library Functions Manual random(3)
Name
random, srandom, initstate, setstate - better random number generator; routines for changing generators
Syntax
long random()
void srandom(seed)
int seed;
char *initstate(seed, state, n)
unsigned seed;
char *state;
int n;
char *setstate(state)
char *state;
Description
The subroutine uses a non-linear additive feedback random number generator employing a default table of size 31 long integers to return
successive pseudo-random numbers in the range from 0 to (2**31)-1. The period of this random number generator is very large, approximately
16*((2**31)-1).
The subroutines have (almost) the same calling sequence and initialization properties as The difference is that rand(3) produces a much
less random sequence - in fact, the low dozen bits generated by rand go through a cyclic pattern. All the bits generated by are usable.
For example, "random()&01" will produce a random binary value.
Unlike does not return the old seed; the reason for this is that the amount of state information used is much more than a single word.
(Two other routines are provided to deal with restarting/changing random number generators.) Like however, will by default produce a
sequence of numbers that can be duplicated by calling with 1 as the seed.
The routine allows a state array, passed in as an argument, to be initialized for future use. The size of the state array (in bytes) is
used by to decide how sophisticated a random number generator it should use - the more state, the better the random numbers will be. (Cur-
rent "optimal" values for the amount of state information are 8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to the
nearest known amount. Using less than 8 bytes will cause an error). The seed for the initialization (which specifies a starting point for
the random number sequence, and provides for restarting at the same point) is also an argument. returns a pointer to the previous state
information array.
Once a state has been initialized, the routine provides for rapid switching between states. The subroutine returns a pointer to the previ-
ous state array; its argument state array is used for further random number generation until the next call to or
Once a state array has been initialized, it may be restarted at a different point either by calling (with the desired seed, the state
array, and its size) or by calling both (with the state array) and (with the desired seed). The advantage of calling both and is that the
size of the state array does not have to be remembered after it is initialized.
With 256 bytes of state information, the period of the random number generator is greater than 269, which should be sufficient for most
purposes.
Diagnostics
If is called with less than 8 bytes of state information, or if detects that the state information has been garbled, error messages are
printed on the standard error output.
See Also
rand(3)
random(3)