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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
you have got a lot of help using awk/perl from your previous posts (since 2 years ago), which are strangely similar to this one. you are still doing ldap stuff and formatting the output. What have you learnt this 2 years since 2007? I would expect you to be very familiar with awk/perl already.
you have got a lot of help using awk/perl from your previous posts (since 2 years ago), which are strangely similar to this one. you are still doing ldap stuff and formatting the output. What have you learnt this 2 years since 2007? I would expect you to be very familiar with awk/perl already.
Since you aren't getting this, I'll explain it to you. Someone figured out they could write a pretty good computer program by asking endless questions in a newsgroup. It's called "programming by newsgroup" and it takes a long, long time.
Programming by newsgroup (PBN) is sort of like throwing a bunch of proteins into a hot salt water bath, coming back in five years, and seeing what's growing. The most advanced PBN projects use a kind of bot that could almost pass the Turing test, but only if the computer side of the test is allowed to sound totally illiterate -- u knw wht i mn?
So a bot asks a question, someone answers, and the bot inserts the suggestion into a disorganized database of code. Then a genetic algorithm churns for a while, comes up with something new, and the process repeats.
Why do you think there are so many people asking questions who clearly cannot type or think? The answer is obvious: they're -- how shall I say this diplomatically -- synthetic people. As people they're a disaster, but as clone-bots, they're quite impressive.
Some of you may think this is fiction, and today, well, yes, it might just be fiction. But tomorrow? Or a week from now?
This perl version might do you:
#!/usr/bin/perl
my $filename = "a.txt";
open (my $filein, "<", "$filename") or die "can't open $filename";
open (my $fileout, ">b.txt");
my $lc=0;
while (<$filein>) {
my $x=$_;
$x =~ s/\n/ /x;
$line{$lc}=$x;
$lc++;
if ($lc == 3) {
print $fileout $line{$lc-2},$line{$lc-1},$_;
$lc=0;
}
}
# check for unfinished line
if ($lc > 0) {
for (my $x=1;$x<=$lc;$x++) {
print $fileout $line{$x};
}
print "\n";
}
This isn't an "improvement", but it does make the sed script produce the "same" output as the original specs
sed '/dn:/,/created/{ /dn/N
/status/N
/created/{s/\n/ /g}
}' test.txt
Since you aren't getting this, I'll explain it to you. Someone figured out they could write a pretty good computer program by asking endless questions in a newsgroup. It's called "programming by newsgroup" and it takes a long, long time.
Programming by newsgroup (PBN) is sort of like throwing a bunch of proteins into a hot salt water bath, coming back in five years, and seeing what's growing. The most advanced PBN projects use a kind of bot that could almost pass the Turing test, but only if the computer side of the test is allowed to sound totally illiterate -- u knw wht i mn?
So a bot asks a question, someone answers, and the bot inserts the suggestion into a disorganized database of code. Then a genetic algorithm churns for a while, comes up with something new, and the process repeats.
Why do you think there are so many people asking questions who clearly cannot type or think? The answer is obvious: they're -- how shall I say this diplomatically -- synthetic people. As people they're a disaster, but as clone-bots, they're quite impressive.
Some of you may think this is fiction, and today, well, yes, it might just be fiction. But tomorrow? Or a week from now?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.