Sponsored Content
Full Discussion: PERL & KSH Big Question
Top Forums UNIX for Dummies Questions & Answers PERL & KSH Big Question Post 73521 by vino on Thursday 2nd of June 2005 10:33:20 AM
Old 06-02-2005
Got a solution .. Smilie

Code:
#! /bin/sh
for key in I B R
do
 for length in 1 2 3 4 5
 do
  LineNo= 
  HASH=
   while read line
   do
     if [[ $line = *${key}${length}* ]] ; then
      LineNo=${LineNo}" "`echo $line | awk -F" " '{ print $1 }'`
     fi;
   done < entry.txt
  HASH=${key}${length}" "${LineNo}
  echo "--"$HASH
  echo $HASH >> entry.txt.output
done
done

entry.txt is your sample input flat file.
Iterations in key and length depend on the different hash key and values.

And the output file looks like

Code:
I1 L1 L3
I2 L2 L5
I3 L2
I4
I5
B1 L1 L2 L5
B2 L4
B3
B4
B5
R1 L1 L4
R2 L2
R3 L3
R4 L5
R5

Cheers !
Vino
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl conversion & perldoc question

Working my way through a perl book and can't find this; You can convert from binary to ordinal numbers using 0b in front of the binary value but how do you go the other way, from ordinal to binary? Is there a function for this? On Perldoc, is there a document that gives all of the available... (2 Replies)
Discussion started by: thumper
2 Replies

2. Shell Programming and Scripting

Perl or awk/egrep from big files??

Hi experts. In one thread i have asked you how to grep the string from the below sample file- Unfortunately the script did not gave proper output (it missed many strings). It happened may be i did gave you the proper contents of the file That was the script- "$ perl -00nle'print join... (13 Replies)
Discussion started by: thepurple
13 Replies

3. Shell Programming and Scripting

perl newbie . &&..programming newbie (question 2)

Hello everyone, I am having to do a lot of perl scripting these days and I am learning a lot. I have this problem I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files.. there is folder1\folder2\*.gz and there are about 50 folders... (1 Reply)
Discussion started by: xytiz
1 Replies

4. Shell Programming and Scripting

perl help to split big verilog file into smaller ones for each module

Hi I have a big verilog file with multiple modules. Each module begin with the code word 'module <module-name>(ports,...)' and end with the 'endmodule' keyword. Could you please suggest the best way to split each of these modules into multiple files? Thank you for the help. Example of... (7 Replies)
Discussion started by: return_user
7 Replies

5. Shell Programming and Scripting

Find & Replace string in multiple files & folders using perl

find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g' this is simple logic to find and replace in multiple files & folders Hope this helps. Thanks Zaheer (0 Replies)
Discussion started by: Zaheer.mic
0 Replies

6. Shell Programming and Scripting

combination between || and && in IF condition with ksh

Dear All, Please advice about this issue. when i run this line in a script if && || && || && if i enter $x = test3 and $y = test1 the If condition apply while it should not Best Regards (2 Replies)
Discussion started by: islam.said
2 Replies

7. Shell Programming and Scripting

awk Help: quick and easy question may be: How to use &&

Hi Guru's. I am trying to use to check if $5 is greater than 80 & if not 100, then to print $0 : awk '{ if ($5>80) && if ($5 != 100) print $0} But getting error: >bdf1|sed 's/%//g'|awk '{ if ($5>80) && if ($5 != 100) print $0}' syntax error The source line is 1. The error... (6 Replies)
Discussion started by: rveri
6 Replies
SLAPD-PERL(5)                                                   File Formats Manual                                                  SLAPD-PERL(5)

NAME
slapd-perl - Perl backend to slapd SYNOPSIS
/etc/ldap/slapd.conf DESCRIPTION
The Perl backend to slapd(8) works by embedding a perl(1) interpreter into slapd(8). Any perl database section of the configuration file slapd.conf(5) must then specify what Perl module to use. Slapd then creates a new Perl object that handles all the requests for that par- ticular instance of the backend. You will need to create a method for each one of the following actions: * new # creates a new object, * search # performs the ldap search, * compare # does a compare, * modify # modifies an entry, * add # adds an entry to backend, * modrdn # modifies an entry's rdn, * delete # deletes an ldap entry, * config # module-specific config directives, * init # called after backend is initialized. Unless otherwise specified, the methods return the result code which will be returned to the client. Unimplemented actions can just return unwillingToPerform (53). new This method is called when the configuration file encounters a perlmod line. The module in that line is then effectively `use'd into the perl interpreter, then the new method is called to create a new object. Note that multiple instances of that object may be instantiated, as with any perl object. The new method receives the class name as argument. search This method is called when a search request comes from a client. It arguments are as follows: * object reference * base DN * scope * alias dereferencing policy * size limit * time limit * filter string * attributes only flag (1 for yes) * list of attributes to return (may be empty) Return value: (resultcode, ldif-entry, ldif-entry, ...) compare This method is called when a compare request comes from a client. Its arguments are as follows. * object reference * dn * attribute assertion string modify This method is called when a modify request comes from a client. Its arguments are as follows. * object reference * dn * a list formatted as follows ({ "ADD" | "DELETE" | "REPLACE" }, attributetype, value...)... add This method is called when a add request comes from a client. Its arguments are as follows. * object reference * entry in string format modrdn This method is called when a modrdn request comes from a client. Its arguments are as follows. * object reference * dn * new rdn * delete old dn flag (1 means yes) delete This method is called when a delete request comes from a client. Its arguments are as follows. * object reference * dn config This method is called once for each perlModuleConfig line in the slapd.conf(5) configuration file. Its arguments are as follows. * object reference * array of arguments on line Return value: nonzero if this is not a valid option. init This method is called after backend is initialized. Its argument is as follows. * object reference Return value: nonzero if initialization failed. CONFIGURATION
These slapd.conf options apply to the PERL backend database. That is, they must follow a "database perl" line and come before any subse- quent "backend" or "database" lines. Other database options are described in the slapd.conf(5) manual page. perlModulePath /path/to/libs Add the path to the @INC variable. perlModule ModName `Use' the module name ModName from ModName.pm filterSearchResults Search results are candidates that need to be filtered (with the filter in the search request), rather than search results to be returned directly to the client. perlModuleConfig <arguments> Invoke the module's config method with the given arguments. EXAMPLE
There is an example Perl module `SampleLDAP' in the slapd/back-perl/ directory in the OpenLDAP source tree. ACCESS CONTROL
The perl backend does not honor any of the access control semantics described in slapd.access(5); all access control is delegated to the underlying PERL scripting. Only read (=r) access to the entry pseudo-attribute and to the other attribute values of the entries returned by the search operation is honored, which is performed by the frontend. WARNING
The interface of this backend to the perl module MAY change. Any suggestions would greatly be appreciated. Note: in previous versions, any unrecognized lines in the slapd.conf file were passed to the perl module's config method. This behavior is deprecated (but still allowed for backward compatibility), and the perlModuleConfig directive should instead be used to invoke the module's config method. This compatibility feature will be removed at some future date. FILES
/etc/ldap/slapd.conf default slapd configuration file SEE ALSO
slapd.conf(5), slapd(8), perl(1). OpenLDAP 2012/04/23 SLAPD-PERL(5)
All times are GMT -4. The time now is 12:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy