Sponsored Content
Full Discussion: words extracting
Top Forums Shell Programming and Scripting words extracting Post 302415954 by durden_tyler on Friday 23rd of April 2010 10:19:29 PM
Old 04-23-2010
Quote:
Originally Posted by hudson03051nh
...
Code:
dn: uid=test,ou=test,dc=com
description: password
sunIdentityServerDeviceStatus: Active
uid: test
objectClass: sunIdentityServerDevice
objectClass: iplanet-am-user-service
objectClass: top
objectClass: iPlanetPreferences
sunIdentityServerDeviceType: blabla
cn: default
sunIdentityServerDeviceVersion: 2.2

How do I extract, test,password,active,test,blabla values into a test file with pipe delimiter ? ...
Here's one way to do it with Perl:

Code:
$ 
$ 
$ cat -n data.txt
     1    dn: uid=test1,ou=test,dc=com
     2    description: password1
     3    sunIdentityServerDeviceStatus: Active1
     4    uid: TEST1
     5    objectClass: sunIdentityServerDevice
     6    objectClass: iplanet-am-user-service
     7    objectClass: top
     8    objectClass: iPlanetPreferences
     9    sunIdentityServerDeviceType: blabla1
    10    cn: default
    11    sunIdentityServerDeviceVersion: 2.2
    12    
    13    dn: uid=test2,ou=test,dc=com
    14    description: password2
    15    sunIdentityServerDeviceStatus: Active2
    16    uid: TEST2
    17    objectClass: sunIdentityServerDevice
    18    objectClass: iplanet-am-user-service
    19    objectClass: top
    20    objectClass: iPlanetPreferences
    21    sunIdentityServerDeviceType: blabla2
    22    cn: default
    23    sunIdentityServerDeviceVersion: 2.2
$ 
$ ##
$ perl -lne 'if (/.*uid=(.*?),.*$/){$x.=$1}
             elsif(/(description|sunIdentityServerDeviceStatus|uid|sunIdentityServerDeviceType): (.*)$/){$x.="|$2"}
             elsif(/^$/ or eof){print $x; $x=""}' data.txt
test1|password1|Active1|TEST1|blabla1
test2|password2|Active2|TEST2|blabla2
$ 
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extracting some words

i run a command that submits a word to WordNET which stores the search results in a document which looks like this... i searched "car" in this instance and id like to extract auto, automobile, machine, and store it in a file with the , , stripped away just the words. WordNET's results' template... (2 Replies)
Discussion started by: mark_nsx
2 Replies

2. Shell Programming and Scripting

Extracting Text Between Two Words

Hi all! Im trying to extract a portion of text from a KML and put it into a new file. Im trying to get all of the points out of it, ignoring everything else so I need only the text between <Placement> and </Placement>. Is there a way to make it extract all instances of these points and not just... (2 Replies)
Discussion started by: Grizzly
2 Replies

3. Shell Programming and Scripting

Extracting part of line between two words

Hi, I have a file few hundred MB's with text like one below in single line. 20091117 abc xyg 20091117 def ghi 20091118 ppp ttt 20091118 zzz zzz xxx I need to extract part of line from 1st occurence of pattern 20091117 till first occurence of another pattern 20091118. I tried... (3 Replies)
Discussion started by: artistic94555
3 Replies

4. UNIX for Dummies Questions & Answers

Extracting only words from a log file

hello: i have a file and i am trying to extract only unique words from that file. i used the command: cat messages.1 | tr " " "\n" | sort | uniq -c but using this command outputs everything unique in the file be it words, numbers, like all the characters..i need a command which will only... (6 Replies)
Discussion started by: vikbenq
6 Replies

5. Shell Programming and Scripting

Help with extracting words from fixed length files

I am very new to scripting and need to write a script that will extract the account number from a line that begins with HDR. For example, the file is as follows HDR2010072600300405505100726 00300405505 LBJ FREEWAY DALLAS TELEGRAPH ... (9 Replies)
Discussion started by: bds052189
9 Replies

6. Shell Programming and Scripting

Extracting words from file

I am having a file from which i need to extract different length words into different file. For example 2 letter word into file2, 3 letter word into file3 and so on.... I did one using grep and shell script.. for (( i=1; i<7; i++)) do egrep -o '\<\(?{$i}\)?\>' $1 | sort -u -f|tr >file$i... (4 Replies)
Discussion started by: akhay_ms
4 Replies

7. Shell Programming and Scripting

grep - Extracting multiple key words from stdout

Hello. From command line, the command zypper info nxclient return a bloc of data : linux local # zypper info nxclient Loading repository data... Reading installed packages... Information for package nxclient: Repository: zypper_local Name: nxclient Version: 3.5.0-7 Arch: x86_64... (7 Replies)
Discussion started by: jcdole
7 Replies

8. Shell Programming and Scripting

Extracting Words from Text

Hi there, Unix Gurus Back in September last year you helped me find a way to extract the words in brackets in a textfile to a new one. In that case my textfile was made up of sentences containing an only bracketed word per sentence/line: 1. If the boss's son had been , someone would... (9 Replies)
Discussion started by: eldeingles
9 Replies

9. Shell Programming and Scripting

Extracting words and lines based on keywords

Hello! I'm trying to process a text file and am stuck at 2 extractions. Hoping someone can help me here: 1. Given a line in a text file and given a keyword, how can I extract the word preceeding the keyword using a shell command/script? For example: Given a keyword "world" in the line: ... (2 Replies)
Discussion started by: seemad
2 Replies

10. Shell Programming and Scripting

Gawk gensub, match capital words and lowercase words

Hi I have strings like these : Vengeance mitt Men Vengeance gloves Women Quatro Windstopper Etip gloves Quatro Windstopper Etip gloves Girls Thermobite hooded jacket Thermobite Triclimate snow jacket Boys Thermobite Triclimate snow jacket and I would like to get the lower case words at... (2 Replies)
Discussion started by: louisJ
2 Replies
SLAPO-AUDITLOG(5)						File Formats Manual						 SLAPO-AUDITLOG(5)

NAME
slapo-auditlog - Audit Logging overlay to slapd SYNOPSIS
/etc/openldap/slapd.conf /etc/openldap/slapd.d DESCRIPTION
The Audit Logging overlay can be used to record all changes on a given backend database to a specified log file. Changes are logged as standard LDIF, with an additional comment header giving the timestamp of the change and the identity of the user making the change. For Add and Modify operations the identity comes from the modifiersName associated with the operation. This is usually the same as the requestor's identity, but may be set by other overlays to reflect other values. CONFIGURATION
This slapd.conf option applies to the Audit Logging overlay. It should appear after the overlay directive. auditlog <filename> Specify the fully qualified path for the log file. olcAuditlogFile <filename> For use with cn=config EXAMPLE
The following LDIF could be used to add this overlay to cn=config (adjust to suit) dn: olcOverlay=auditlog,olcDatabase={1}hdb,cn=config changetype: add objectClass: olcOverlayConfig objectClass: olcAuditLogConfig olcOverlay: auditlog olcAuditlogFile: /tmp/auditlog.ldif FILES
/etc/openldap/slapd.conf default slapd configuration file /etc/openldap/slapd.d default slapd configuration directory SEE ALSO
slapd.conf(5), slapd-config(5). OpenLDAP 2.4.28 2011/11/24 SLAPO-AUDITLOG(5)
All times are GMT -4. The time now is 03:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy