Multiple String with a number replacement and more..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple String with a number replacement and more..
# 1  
Old 01-10-2010
Multiple String with a number replacement and more..

Hello all,
First of all, I could not made up a nice title what explains my problem in short,sorry for that already.

I have the next file which contains the following,
Code:
CREATE:ENTRY:\
        DNAME,"referenceId=sondakika30,referenceId=User1,\
                referenceId=Company,\
                application=3rdPatrty,machineName=panama":\
        referenceId,sondakika30:\
        name,"sondakika30":\
        language,English:\
        publicNumber,"3000555":\
        shortNumber,"555":

What I want is to add on "sondakika30" + 1, so it will be sondakika31, and same to the numbers (publicNumber +1, shortNumber+1) till like 1000 in the same file, so for example I will get the following adding 1.

Code:
CREATE:ENTRY:\
        DNAME,"referenceId=sondakika30,referenceId=User1,\
                referenceId=Company,\
                application=3rdPatrty,machineName=panama":\
        referenceId,sondakika30:\
        name,"sondakika30":\
        language,English:\
        publicNumber,"3000555":\
        shortNumber,"555":



CREATE:ENTRY:\
        DNAME,"referenceId=sondakika31,referenceId=User1,\
                referenceId=Company,\
                application=3rdPatrty,machineName=panama":\
        referenceId,sondakika31:\
        name,"sondakika31":\
        language,English:\
        publicNumber,"3000556":\
        shortNumber,"556":
::::
::::
etc.


Please can someone lead me to the right direction, how to start with this ?

many thanks in advance,

Last edited by Scott; 01-10-2010 at 06:33 PM.. Reason: Please use code tags
# 2  
Old 01-10-2010
Code:
awk -v RefID="30" -v PubNo="3000555" -v ShortNo="555" '{for (i=0;i<=1000;i++) 
     {print "CREATE:ENTRY:\\"; 
      print "\t DNAME,\"referenceId=sondakika" RefID+i",referenceId=User1,\\"
      print "\t\t referenceId=Company,\\"
      print "\t\t application=3rdPatrty,machineName=panama\":\\"
      print "\t referenceId,sondakika" RefID+i ":\\"
      print "\t name,\"sondakika" RefID+i "\":\\"
      print "\t language,English:\\"
      print "\t publicNumber,\"" PubNo+i "\":\\"
      print "\t shortNumber,\"" ShortNo+i "\":\n"
     }
}'

# 3  
Old 01-10-2010
wow it works great, thanks, thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String replacement

Hi, I have a text file where all records come in one line (single line file), each record starts with 'BUCH' and ends with '@&' and if data is not there we get space instead. between '@&' and next record there might be some spaces, now I want to remove those spaces between '@&' and 'BUCH'. ... (4 Replies)
Discussion started by: maks475
4 Replies

2. UNIX for Dummies Questions & Answers

Multiple replacement

Hi friends Hope, you all are doing well I need your help for doing multiple strings replacement. I have a file with more than 1000 lines and I want to replace several elements in the same run. I have the equivalences written in another file. Example: target file Start (bp) End (bp) ... (6 Replies)
Discussion started by: lsantome
6 Replies

3. Shell Programming and Scripting

String replacement.

Dear Friends, I want to replace following line with given line. It should grep/search following string in a file (input.txt) M/M SRNO: 000M/6200-0362498 COSMETIC PRO MALE FEMALE Once found it should replace it to following string. T_DLHNNO: 000M/6200-0362498 ... (7 Replies)
Discussion started by: anushree.a
7 Replies

4. Shell Programming and Scripting

Extract string from multiple file based on line count number

Hi, I search all forum, but I can not find solutions of my problem :( I have multiple files (5000 files), inside there is this data : FILE 1: 1195.921 -898.995 0.750312E-02-0.497526E-02 0.195382E-05 0.609417E-05 -2021.287 1305.479-0.819754E-02 0.107572E-01 0.313018E-05 0.885066E-05 ... (15 Replies)
Discussion started by: guns
15 Replies

5. Shell Programming and Scripting

String replacement

Hi All, I have below file which has data in below format. #$ | AB_100 | AB_300 ()| AB_4 @*(% | AB-789 i want o/p as below format. | AB_100 | AB_300 | AB_4 | AB-789 So here there is no standard format. How we can achieve the same in unix ? Regards, (3 Replies)
Discussion started by: gander_ss
3 Replies

6. Shell Programming and Scripting

search for any number, and retain them in replacement

Hello! Here is what I am trying to do: I am taking a class at school that is using a lot of literature that is in the public domain, and available for free on the web. Rather than read them online in HTML, I have been pulling them down and quickly and dirtily tagging them up and typesetting... (4 Replies)
Discussion started by: ccox85
4 Replies

7. Shell Programming and Scripting

String replacement

I have one string string1=user/password:IP_ADDR:Directory I need to replace string1 value like store into string2 string2=user password:IP_ADDR:Directory i.e replace "/" character by '<space>' character But i wouldn't use any file in the meantime. Please help me......................... (6 Replies)
Discussion started by: mnmonu
6 Replies

8. Shell Programming and Scripting

Replacement of string

Hi I have a text file which contains the following. AAA,BBB,CCC,DDD AAA,BBB,CCC,DDD AAA,BBB,CCC,DDD How can I replace all CCC with 888, with other contents inside the file remain unchange? Please advice Desired output: AAA,BBB,888,DDD AAA,BBB,888,DDD AAA,BBB,888,DDD (1 Reply)
Discussion started by: c0384
1 Replies

9. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies

10. Shell Programming and Scripting

String replacement in multiple files

What is the most simple way to search multiple text files in multiple directories for a string then replace it with another string? I have about 300 files that I need to update and I'm just looking for alternatives rather than having to edit each one by hand. Thanks in advance! (2 Replies)
Discussion started by: WABonnett
2 Replies
Login or Register to Ask a Question