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
# 1  
Old 04-07-2014
Help with appending random sequence to huge CDR file

Hi,

I am in a terrible emergency. I have multiple cdr files with line count >6000.
I need to append |0| | | | | | | |random| to end of each line. The random number should never repeat.

Please help with a shell script to process all cdr's in a directory with above requirement.
# 2  
Old 04-07-2014
What have you tried?
# 3  
Old 04-07-2014
What should be the range of the random numbers?
# 4  
Old 04-07-2014
anyrange would be file, all that is need is it has to be unique across 3 million cdrs
# 5  
Old 04-07-2014
Moderator's Comments:
Mod Comment We are not a free scriptwriting service. What have you tried?
# 6  
Old 04-07-2014
random number, I have figured as $date +%N, which can be used. I am not able to come out with the final working script.

---------- Post updated at 04:14 PM ---------- Previous update was at 04:13 PM ----------

this is what , I am trying now

Code:
cntLoop=$date +%N
INP_CSV_FILE="/data101/rating/cs5_upload/med_dir/postpaid/dupgprs/data/testcdr
OUT_CSV_FILE="/data101/rating/cs5_upload/med_dir/postpaid/dupgprs/data/outfile.csv"
pattern='|0| | | | | | | |'
rm -f $OUT_CSV_FILE
for line in `cat $INP_CSV_FILE`
do
        cntloop=$date +%N
        echo $line|0| | | | | | | |$cntloop| >> $OUT_CSV_FILE
done

---------- Post updated at 04:15 PM ---------- Previous update was at 04:14 PM ----------

I am getting below errors

Code:
./test.sh: line 1: +%N: command not found
./test.sh: line 9: syntax error near unexpected token `|'
./test.sh: line 9: `        echo "$line|0| | | | | | | |$cntloop| " >> $OUT_CSV_FILE'

This User Gave Thanks to shiburnair For This Post:
# 7  
Old 04-07-2014
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.
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