So, I have an ldif file that contains about 6500 users worth of data. Some users have a block of text I'd like to remove, while some don't.
Example (block of text in question is the block starting with "authAuthority: ;Kerberosv5"):
User with text block:
Now, one problem is, ldapsearch/ldapdump break up attributes at 76 characters. So, the block in question should be one line.
So I'm curious if there's an easy way to either A. remove the line breaks for the blocks of text (any line that starts with a " " should have the space removed, and should be on the line above. Though, one line starts with " " and only should have one " " removed then get put back with the previous line, or B. just to nuke the whole block of text that starts with "authAuthority: ;Kerberosv5" and ends with "example.com:123.456.789.111".
Anyone have any ideas? (btw, I realize that the line breaks aren't at exactly 76 anymore, since I had to sterilize the text for any personal info).
So, the first one to remove the line breaks works great. The second one, which removes the chunk, doesn't seem to work. The resulting output is significantly truncated (it seems to be removing a very large portion of the file).
Before the second command, the file is 181095 lines. After the sed command, it's 2652. Since there are 6411 users in the ldif file, theoretically, that sed command should only be removing one line per user, so the output should be about 175k lines.
sed should stop it's pattern match at the first "stop" it sees. Could that not be working?
For example...
Here's the output after taking my "input" and running it through the "de-space/de-return sed"
Now here's what comes out after the sed to remove the kerberos block (`sed '/authAuthority: ;Kerberosv5/,/ root@example.com/d' test2.ldif`):
So obviously, something is not quite right...
Thanks!
---------- Post updated 07-30-09 at 10:59 AM ---------- Previous update was 07-29-09 at 07:43 PM ----------
ah ha... okay, so after removing line breaks, the command should be:
Obviously (now) because it's all one line, and sed stops at the first line break after the match.
Assuming I have "username", and "REALM", can anyone think of a good way to turn this:
Into this:
You'll notice that the hex value following the ;ApplePasswordServer; and ;Kerberosv5; are the same, as are the sections beginning with 1024 and ending with root@ldap.example.com:123.456.789.111. So basically, need so swap out ApplePasswordServer with Kerberosv5, and add the username and REALM info.
I can think of a few ways to do this with php, but I'm not particularly good with regex, and it would be nice to do this all in (ba)sh.
Hello experts,
I have a text file with lot of curly brackets (both opening { & closing } ). I need to delete them alongwith the text between opening & closing brackets' pair.
For ex: Input:-
59. Rh1 Qe4 {(Qf5-e4 Qd8-g8+ Kg6-f5
Qg8-h7+ Kf5-e5 Qh7-e7+ Ke5-f5 Qe7-d7+ Qe4-e6 Qd7-h7+ Qe6-g6... (6 Replies)
Hi all,
I'd always appreciate all helps from this site.
I would like to delete duplicated chunks of strings on the same row(?).
One chunk is comprised of four lines such as:
path name
starting point
ending point
voltage number
I would like to delete duplicated chunks on the same... (5 Replies)
Hi
I have a file with different filesystems with there sizes. I need to split them in chucks of 1TB.
The file looks like
vf_MTLHQNASF07_Wkgp2 187428400 10601AW1
vf_MTLHQNASF07_Wkgp2 479504596 10604AW1
vf_MTLHQNASF07_Wkgp2 19940 10605AID
vf_MTLHQNASF07_Wkgp2 1242622044... (4 Replies)
Hello,
I have a large file in which data of names is sorted according to their homographs. The database has the following structure:Each set of homographs with their corresponding equivalents in Devanagari is separated out from the next set by a hard return. An example will make this... (12 Replies)
Hi gurus,
I wanted to split main file in 20 files with 2500 lines in each file. My main file conatins total 2500*20 lines. Following awk I made, but it is breaking with error.
awk '{ for (i = 1; i <= 20; i++) { starts=2500*$i-1; ends=2500*$i; NR>=starts && NR<=ends {f=My$i".txt"; print >> f;... (10 Replies)
First time poster, but the forum has saved my bacon more times than... Lots.
Anyway, I have a text file, and wanted to use Awk (or any other sensible program) to print out overlapping sections, or arbitrary length. To describe by example, for file
1
2
3
4
5
etc...
I want the out put... (3 Replies)
Hi, I need a script that parses and greps data out of a textfile.
I have a text file that has this structure:
File1
host1.localdomain
text random text
Found errors
this text is random (41123) --- random random
at.5165 ---- random random
at.5165 ---- random random
at.5165 ----... (2 Replies)
Hi guys,
i have a question about spliting a binary file into 2 chunks.
First chunk with all high bytes and the second one with all low bytes.
What unix tools can i use? And how can this be performed?
I looked in manpages of split and dd but this does not help.
Thanks (2 Replies)
Hello,
I got files full path in a text file like that
/main/k/kdelibs/kdelibs4c2a_3.5.10.dfsg.1-2ubuntu7_i386.deb
/main/k/kdelibs-experimental/libknotificationitem-dev_4.3.2-0ubuntu1_i386.deb
/main/k/kdemultimedia/dragonplayer_4.3.2-0ubuntu1_i386.deb... (13 Replies)
I am trying to write a script that kills old sessions, I've posted here over the past few days and the script is just about perfect except I want to be given the option to exclude specified PIDs from being killed. this is the entire script:
if
then
rm /tmp/idlepids
fi
if
then
rm... (2 Replies)