Sponsored Content
Top Forums Shell Programming and Scripting adding a number with sed or awk. Post 302682693 by pelama on Monday 6th of August 2012 05:00:14 PM
Old 08-06-2012
adding a number with sed or awk.

Hi.. I have this delicate problem..Smilie I have this huge ldif file with entry's like this example below..

And I need to change the following entrys.

Code:
telephoneNumber:
emNotifNumber:
billingnumber=
BillingNumber:

Al these entrys has a number like 012345678 and it needs to add one more number in begining,, like 9012345678

So
telephoneNumber:012345678 needs to be change to telephoneNumber:9012345678 and so on..

this is a huge file so I would like this to run in one go..
So... Smilie How would I do this?

Code:
# entry-id: 192
dn: uniqueidentifier=um704,ou=C10,ou=site1,o=users
nsUniqueId: a7e6a34b-1dd111b2-80f1bd80-559f9638
modifyTimestamp: 20090617001511Z
modifiersName: uniqueidentifier=um9999999999999999,o=users
mailHost: mail.sugar.pop.us
mailAlternateAddress: 012345678@sugar.pop.us
emFTL: -1,F
BadLoginCount: 0
umpassword: password
Password: password
mailForwardingAddress: 123123@sugar.pop.com
cn: SUGAR POP
sn: SUGAR
givenName: POP
uniqueIdentifier: um704
uid: 012345678
telephoneNumber: 012345678
mailQuota: 7549747
mail: 012345678@sugar.pop.com
emNotifNumber: 012345678
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: nsmessagingserveruser
objectClass: inetmailuser
objectClass: inetlocalmailrecipient
objectClass: LIP
objectClass: emuser
objectClass: emNotification
gender: F
l: 0
preferredLanguage: en
emMessagecharencoding: ISO-8859-1
mailDeliveryOption: mailbox
mailDeliveryOption: forward
emSMPPcenterid: SMSC
emPreferredDateFormat: yyyy/mm/dd
emPreferredTimeFormat: 24
userPassword: userpassword
creatorsName: cn=directory manager
createTimestamp: 20031201054612Z
emServiceDn: cos=20,ou=C10,ou=site1,o=users

# entry-id: 193
dn: billingnumber=012345678,uniqueIdentifier=um704,ou=C10,ou=site1,o=users
nsUniqueId: a7e6a34c-1dd111b2-80f1bd80-559f9638
modifyTimestamp: 20090617001511Z
modifiersName: uniqueidentifier=um9999999999999999,o=users
admininfo: uniqueidentifier=um1p383
BillingNumber: 012345678
AnsweringService: LM
objectClass: top
objectClass: confmsgbox
subscribertimezone: bluemoon/mars
creatorsName: cn=directory manager
createTimestamp: 20031201054612Z
ActiveGreetingId: SpokenName,AllCalls
COSDN: cos=20, ou=C10, ou=site1,o=users

Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 08-06-2012 at 06:17 PM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Truncating a number using sed/awk

Hi all, I'm trying to truncate a number like the following: 0001060407013900501048239559900600504083525826350002050354795057 I would like to create an output which puts carriage returns every so many characters, giving an output such as: 0001 060407 0139 0 05 010482395599 0060... (4 Replies)
Discussion started by: michaeltravisuk
4 Replies

2. UNIX for Dummies Questions & Answers

Adding a new field using sed or awk?

I have a bcp file that contains 10 fields. These fields are separated by a tab. How can I add my name as a new field in the 8th position for every record? I've been playing w/ sed and awk but can't seem to figure this out. (3 Replies)
Discussion started by: sasabune
3 Replies

3. Shell Programming and Scripting

awk/sed - getting string instead of number

Hi! I am writing a script handling downloading list of files and I have to check whether file is present locally and if not finished than continue downloading. To do so I have to compare sizes of remote file and local file. To check remote file size I have to parse something like this: ... (2 Replies)
Discussion started by: hrwath
2 Replies

4. Shell Programming and Scripting

sed/awk-adding numeric to a column

I have a txt file as follows Code: Oct 1 file1 4144 Oct 1 file23 5170 Oct 2 file5 3434 Oct 21 file56 2343 I need to add a new column by marking the right log file from current directory. For example populate like this. Please not in the second columt for "1" it has... (2 Replies)
Discussion started by: gubbu
2 Replies

5. Emergency UNIX and Linux Support

Adding carriage returns to file using sed/awk

Hello, I need help adding carriage returns at specific intervals (say 692 characters) to a text file that's one continous string. I'm working in AIX5.3. Any quick help is appreciated. Thanks! (2 Replies)
Discussion started by: bd_joy
2 Replies

6. UNIX for Dummies Questions & Answers

Adding a column with the row number using awk

Is there anyway to use awk to add a first column to my data that automatically goes from 1 to n , where n is the numbers of my rows?:confused: (4 Replies)
Discussion started by: cosmologist
4 Replies

7. Linux

Adding a prefix to a column using awk/sed commands

Hello, I am a newbie to linux and struggling to find a better way to append a column in a text file. Here is the file i want to modify: It has 8 columns (and thousands of rows). I want to append the first column by adding "chr" infront of the numbers. Some rows have a string in the first... (4 Replies)
Discussion started by: bjorngill
4 Replies

8. Shell Programming and Scripting

Help on Sed/awk/getting line number from file

I Have file1 with below lines : #HostNameSelection=0 :NotUsed #HostNameSelection=1 :Automatic #HostNameSelection=3 :NotForced I have file2 which has similar lines but with different values I want to copy the changes from file1 to file2 ,line by line only if line begins with '#'. for... (7 Replies)
Discussion started by: mvr
7 Replies

9. Shell Programming and Scripting

adding number based on pattern using awk

Hi, I want to add numbers based on pattern . in the below ouput file , i want number to be added after pattern line ---- , ie 1 and next is also 1 and next is 2 and next is 3 after adding 4 numbers say output is 7 should be redirected to another file . like this it should add 4 digits after... (2 Replies)
Discussion started by: raghavendra.nsn
2 Replies

10. Shell Programming and Scripting

Adding text from a variable using sed (Or awk) with punctuation

Hi All, I would have though this would have been simple, but... I have text in a variable that I need to insert into a bunch of other files... The text is simple: ... (2 Replies)
Discussion started by: joeg1484
2 Replies
All times are GMT -4. The time now is 12:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy