ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
cmontr:
Let me see if I can rephrase your question in a way that we can all understand unambiguously. Your ldap database contains records named 'cquestion', which have some values which may or may not be unique. You want the corresponding 'dn' records to be reported, but only for those 'cquestion' records which are unique. You do not want any of the 'cquestion' records reported. Does this accurately express your requirements?
Can someone who understands the ldap database confirm that the records in the database are organized in groups starting with a 'dn' record, and ending with a 'cquestion' record? The snippet of text given in the example would seem to indicate this, and if it is the case, it should simplify the problem.
Ok this runs ok. Now I want to print this in another format - in another words I want to give an input as cquestion when I run the script. When I ran the script is should ask me something like : "Enter your cquestion: " And when I enter, it should do the printing for its dn value which is working. I appreciate if anyone is familiar with it and can help me. Thanks million again.
cquestion when I run the script. When I ran the script is should ask me something like : "Enter your cquestion: " And when I enter, it should do the printing for its dn value which is working. I appreciate if anyone is familiar with it and can help me. Thanks million again.
Hi - I am sorry but that line did not work....grep: can't open -B
Are you running on a Unix or BSD machine. Maybe the -B (as in before) option doesn't exist in your version of grep. My example doesn't place the dn: after cquestion:. To do that you could use sed, using the hold register. This is where you would be better off writing a sed script and running the command like
sed -f dn_cquestion.sed ldapjunk.txt
Where dn_cquestion is a sed script. Also if there are dn's without corresponding cquestion's then you may need to branch out when another dn is read.
The exceptions are what can make using sed very complicated. Often when you have patterns over a range of files, you need to use the advanced options and build up lines in the input register or use the hold register.
Hi - What I am trying to print out every field for the particular question in the file...earlier I was printing only dn value for the asked question in this file...I tried your script but did not work. Could you please take a look again? thank you very much. This was the old code to print dn from the question in the txt file.
What did it give you? And where did you create the file? Is it using
Unix or DOS line-ends? If it's from DOS my thing won't work - convert
it to Unix first ...
What did it give you? And where did you create the file? Is it using
Unix or DOS line-ends? If it's from DOS my thing won't work - convert
it to Unix first ...
Cheers,
Tink
================
It is in unix - solaris os.
i put that in a script
#!/usr/bin/awk -f
awk 'BEGIN{RS=ORS="\n\n"; FS=OFS="\n"} /cquestion: What is your name?/ {print $0}'
and ran as:
awk -f test.awk a.txt > test.txt where a.txt contains the data file and test.txt is to be the extracted file
error I got was
awk: syntax error near line 3
awk: bailing out near line 3
OK ... use the GNU awk instead of the Solaris default one - if it's not installed
(yet) you can grab if from sun's download site. The thing that comes with Solaris
by default is cr*p.
OK ... use the GNU awk instead of the Solaris default one - if it's not installed
(yet) you can grab if from sun's download site. The thing that comes with Solaris
by default is cr*p.
Cheers,
Tink
==========
I am sorry but I only have user account on the server as oracle
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.