Computing.Net > Forums > Unix > eliminiate white spaces in script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

eliminiate white spaces in script

Reply to Message Icon

Name: NM
Date: September 25, 2003 at 12:50:03 Pacific
OS: Solaris
CPU/Ram: SPARC
Comment:

Hi guys,

I hv to eliminiate the white spaces from following entry.

for eg:
uid=AdminCFT1, ou=adminaccount, o=xyz, dc=com

In above entry space is their after , (comma) [between uid= upto =com ]

First I hv to find which dn: entry has space & space is their them remove that space.I got 65000 entries.

=====================================
Entry examples:
=====================================
dn: uid=AdminCFT1, ou=adminaccount, o=xyz, dc=com
objectClass: AdminAccount
objectClass: simpleSecurityObject
objectClass: top
userPassword: {SSHA}m0//7Z5RH0CSP1UUecezLR5D8+jZAEspa0ZbCQ==
uid: ADMINCFT1

dn: uid=AdminSCPM1, ou=adminaccount, o=xyz, dc=com
objectClass: top
objectClass: simpleSecurityObject
objectClass: AdminAccount
uid: ADMINSCPM1
userPassword: {CRYPT}9IWaaVNDcr1j.

dn: uid=AdminCSC1, ou=adminaccount, o=xyz, dc=com
objectClass: simpleSecurityObject
objectClass: top
objectClass: AdminAccount
uid: ADMINCSC1
owner: uid=A611753,ou=account,o=xyz,dc=com
owner: uid=ZZ36784,ou=account,o=xyz,dc=com
userPassword: {SSHA}

dn: uid=ownertoolkit,ou=adminaccount,o=xyz,dc=com
objectClass: top
objectClass: simpleSecurityObject
objectClass: AdminAccount
userPassword: {SSHA}TEKGInbR4dU50eWvZg0GBxO4DGJVMxAfYmcvPw==
uid: OWNERTOOLKIT



Sponsored Link
Ads by Google

Response Number 1
Name: FishMonger
Date: September 26, 2003 at 00:12:40 Pacific
Reply:

Here's a perl in-line edit command line "script" that will do it.

perl -pi -e 'if(/^dn:/i){s/,\s+/,/g'} script.file

if you what to create a backup file incase something goes wrong, change it to this:

perl -pi.bak -e 'if(/^dn:/i){s/,\s+/,/g'} script.file


0

Response Number 2
Name: NM
Date: September 29, 2003 at 08:12:19 Pacific
Reply:

Thanks but I am using korn shell scripting not perl.



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


gawk syntax error shellscript help



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: eliminiate white spaces in script

bash script www.computing.net/answers/unix/bash-script/7876.html

please help in Scripting www.computing.net/answers/unix/please-help-in-scripting/8405.html

Logic in possible in Scripts www.computing.net/answers/unix/logic-in-possible-in-scripts/5591.html