[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: помогите с sed и подпрограммой



On Wed, Jun 19, 2013 at 09:23:43AM +0400, Владимир Скубриев wrote:
> Вот кусок исходного файла:
> 
> # anthropics, users, example.lab
> dn: cn=anthropics,ou=users,dc=example,dc=lab
> cn: Anthropics Client
> cn: anthropics
> description: Anthropics Client
> gidNumber: 1901
> homeDirectory: /home/anthropics
> loginShell: /bin/bash
> mail: [1]anthropics@example.com
> objectClass: simpleSecurityObject
> objectClass: inetOrgPerson
> objectClass: posixAccount
> objectClass: shadowAccount
> sn: Anthropics
> uid: anthropics
> uidNumber: 2019
> userPassword:: e1NIQX1vTzU2WHBYMlU3cmZFWkJpL3I4UGUvYjNyb0k9
> 
> # apotash01, users, example.lab
> dn: cn=apotash01,ou=users,dc=example,dc=lab
> cn: Adam Potash
> cn: apotash01
> description: Passenger monitoring project
> gidNumber: 1901
> homeDirectory: /home/apotash01
> loginShell: /bin/bash
> mail: [2]apotash01@example.com
> objectClass: simpleSecurityObject
> objectClass: inetOrgPerson
> objectClass: posixAccount
> objectClass: shadowAccount
> sn: Potash
> uid: apotash01
> uidNumber: 2032
> userPassword:: e1NIQX1rVGkyNVBYd3FOZlNURXZkT1d3Q1FPZGZ5OVk9

$ sed -r 's/(userPassword:: )(.*)/echo -n "\1"; echo \2 | base64 -d/e' file
# anthropics, users, example.lab
dn: cn=anthropics,ou=users,dc=example,dc=lab
cn: Anthropics Client
cn: anthropics
description: Anthropics Client
gidNumber: 1901
homeDirectory: /home/anthropics
loginShell: /bin/bash
mail: anthropics@example.com
objectClass: simpleSecurityObject
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
sn: Anthropics
uid: anthropics
uidNumber: 2019
userPassword:: {SHA}oO56XpX2U7rfEZBi/r8Pe/b3roI=

# apotash01, users, example.lab
dn: cn=apotash01,ou=users,dc=example,dc=lab
cn: Adam Potash
cn: apotash01
description: Passenger monitoring project
gidNumber: 1901
homeDirectory: /home/apotash01
loginShell: /bin/bash
mail: apotash01@example.com
objectClass: simpleSecurityObject
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
sn: Potash
uid: apotash01
uidNumber: 2032
userPassword:: {SHA}kTi25PXwqNfSTEvdOWwCQOdfy9Y=

-- 
wbr, alexander barakin aka sash-kan.
-- 
i will be very thankful to you if you will use natural for the human order:
first question, then the answer.

Attachment: signature.asc
Description: Digital signature


Reply to: