K
K
kiper-prog2019-12-28 12:23:27
linux
kiper-prog, 2019-12-28 12:23:27

How to cut certain lines in command output?

dn: uid=user,ou=exempl,dc=org,dc=local
cn:: 0JDQvdCw0YLQvtC70LjQu
sn:: 0JDQvdC
givenName:: 0JDQvdCw
description:: 0KHQuNGB0YLQtdC80Lww0YLQvtGA
uid: user
loginShell: /bin/bash
uid333: shadowNumber
:
43 @ mail user
gosaMailDeliveryMode: []
gidNumber: 5000
HomeDirectory: / home / user
the userPassword :: FEegflrrhlhfdeffetbvgrt the
objectClass: the inetOrgPerson the
objectClass: the organizationalPerson
sshPublicKey: the ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3F2wh9fq8SSdehtEfrtg
RAI2LqVIy4YYBQZSC5TXcyGJg8fiOWupooeJIXSFbeDilIrvEju0htfXfn2WzTn93 ++ lnoTKOvo82
RIhADmUyrZKd1vuZhVbqRQICEID3kxuoM47igHykMlW11kZhuh07+xw1y2B5yLlMqjc6tqBqZRVB1
0iNXbIud [email protected]
# search result
search: 2
result: 0 Success
How to strip the output of the sshPublicKey:... command? With awk or sed

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
kiper-prog, 2020-12-30
@kiper-prog

sed -n '/^ /{H;d};/sshPublicKey:/x;$g;s/\n *//g;s/sshPublicKey: //gp'

V
vreitech, 2019-12-28
@fzfx

grep -P '^sshPublicKey:' | grep -oP '\w+$'

K
ky0, 2019-12-28
@ky0

And in ldapsearchor what do you output there, you did not think to use the filter of output parameters?

M
mayton2019, 2019-12-29
@mayton2019

grep -v leaves all text except the specified pattern.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question