Help with appending random sequence to huge CDR file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with appending random sequence to huge CDR file
# 8  
Old 04-07-2014
Quote:
Originally Posted by Corona688
How about a number like 0000(number of file)0000(line number)? That's going to be unique. A truly random one runs the risk of being not.
That would be perfect
# 9  
Old 04-07-2014
How does this work on one file:
Code:
awk 'FNR==1 {
        FNUM++
        if(LF) close(LF);
        LF=FILENAME".out"
}
{    printf("%s|0| | | | | | | |%08d%08d|\n", FNUM, FNR) > LF; }' input.cdr


Last edited by Corona688; 04-07-2014 at 06:30 PM.. Reason: Fixed a typo, moved ;
# 10  
Old 04-07-2014
awk: cmd. line:5: { printf("%s|0| | | | | | | |%08d%08d|\n", FNUM, FNR);> LF }
awk: cmd. line:5: ^ syntax error

---------- Post updated at 04:34 PM ---------- Previous update was at 04:31 PM ----------

sample cdr format : i need to append to the end of each line like below mentioned extra columns and a random no followed by |. so as to make each cdr undoubtedly unique

0|1|0|20140406020532| |205| |5|0|620| |502| | |999933992| |3| | | |0|V:11:620:74043720:74043100|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0| 0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0|0:0:0:0:0| 0:0:0:0:0| |550|internet|502|0|0| |3333| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
# 11  
Old 04-07-2014
There were some mistakes in my original try, how about this:

Code:
awk 'FNR==1 {
        FNUM++
        if(LF) close(LF);
        LF=FILENAME".out"
}
{    printf("%s|0| | | | | | | |%08d%08d|\n", $0, FNUM, FNR) > LF; }' input.cdr

# 12  
Old 04-07-2014
Looks perfect friend, Just please tell me, how to pick all files in a dir and do above appending. I am asking for this because, I have to deal with exact 45-50 files with 60k cdr's in each file.
# 13  
Old 04-07-2014
Do these files have anything in common with each other? What do they look like?
# 14  
Old 04-07-2014
After %s , space was needed as to provide a column width between last | and the first | we added. I made that change to the script you provided

---------- Post updated at 04:45 PM ---------- Previous update was at 04:44 PM ----------

In post#10, i provided a sample cdr, these files will have n number of lines with same cdr format
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. BSD

Mcookie, pkg -l to generate random sequence

I am setting this thread to this bsd forum, though it may fit into bash. But as using bsd and the terminal, I would like to generate a random sequence of alphanumerical digits, such as I use to do so on linux by typing just mcookiethis one gives me a pretty random password, but it does not on bsd... (0 Replies)
Discussion started by: 1in10
0 Replies

2. Shell Programming and Scripting

Appending sequence number at the end of file name

hi team, i need a script for renaming a file with sequence number. script get a file from one directory'/home/billing/Cmm/sms/sms_tmp' append sequence no at the end of file name and move a file to other directory/home/billing/Cmm/sms/. actual file is cdr201508271527 file after renaming ... (3 Replies)
Discussion started by: mfaizan40
3 Replies

3. Shell Programming and Scripting

Need to generate a file with random data. /dev/[u]random doesn't exist.

Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom. I create a named pipe then: dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024 but when I cat a file to the fifo that's 1024 random bytes: cat randomfile.txt >... (7 Replies)
Discussion started by: Devyn
7 Replies

4. Shell Programming and Scripting

find common entries and match the number with long sequence and cut that sequence in output

Hi all, I have a file like this ID 3BP5L_HUMAN Reviewed; 393 AA. AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3; DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot. DT 05-JUL-2004, sequence version 1. DT 05-SEP-2012, entry version 71. FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies

5. Shell Programming and Scripting

CDR manupulation

Hello Friends, I need to examine a huge CDR file according to a complex (at least for me) condition like below and i couldnt write anything :( In CDR file there are more than hundreds of fields, I need to print the rows which matches the below condition: while $13 field of subsequent... (9 Replies)
Discussion started by: EAGL€
9 Replies

6. UNIX for Dummies Questions & Answers

Adding a running sequence number while appending 2 files

Hi, I have to append 2 files and while appending i need to add a running sequence number (counter ) for each line at the first column. For e.g. If file x contains details as below. Tom Dick Harry Charlie and file y contains Boston Newyork LA Toledo Then the new file should... (1 Reply)
Discussion started by: kalyansid
1 Replies

7. Shell Programming and Scripting

parsing large CDR XML file

Dear Freind in the file attached how parse the data to be like a normal table :D (3 Replies)
Discussion started by: saifsafaa
3 Replies

8. UNIX for Dummies Questions & Answers

how can i isolate the random sequence of numbers using awk?

as you can see there is a delimiter after c8 "::". Awk sees the rest as fields because it doesn't recognize spaces and tabs as delimiters. So i am basically looking to isolate 20030003ba13f6cc. Can anyone help? c8::20030003ba13f6cc disk connected configured unknown (2 Replies)
Discussion started by: rcon1
2 Replies

9. UNIX for Dummies Questions & Answers

Generating a CDR file using PHP scripts.

Hi, I need to do croning in PHP to generate a CDR (Call Details Record) file daily from the mysql database. The CDR file has to be named in a certain sequence such as xx00000xxx200604080850.cdr. A new file is written every day. The generated CDR file is then ftp over to a server. I am... (0 Replies)
Discussion started by: kurl
0 Replies

10. Filesystems, Disks and Memory

writing to a cdr drive.

ive looked around for software to do this in linux, but am still not sure how to. i want to be able to mount a cdr and write to it and be able to take the disk out and finish writing whatever i want to it at a later time. can we do this in linux? (4 Replies)
Discussion started by: norsk hedensk
4 Replies
Login or Register to Ask a Question