Hi all,
First off, Thank you all for the knowledge I have gleaned from this site!
Deleting Records from a text file... sed paragraphs
The following code works nearly perfect, however each time it is run on the log file it adds a newline at the head of the file, run it 5 times, it'll have 5 blank lines at the head of the file.
I have been unable to figure out why or how to prevent it.
Newlines should be after the record, not before.
Also, How big of file can sed handle like this??
The code: (I have made it into a here doc for example)
#!/bin/sh
matchitem=' Using archive: /mnt/Raid/test/Backup_20090824@051500.tbz'
item2del=$(echo "${matchitem}" | sed 's:[]\[\^\$\.\*\/]:\\&:g')
sed -n '
/Backup started:/ b paragraph
H
$ b paragraph
b
:paragraph
x
/'"${item2del}"'/!p' <<EOF
Backup started: Sat Aug 22 05:15:00 EDT 2009, MyBackup v3.0.8
Using archive: /mnt/Raid/test/Backup_20090822@051500.tbz
Backup completed: 293,437,440 bytes in 131 seconds at 05:17:11 EDT
Backup started: Sun Aug 23 05:15:00 EDT 2009, MyBackup v3.0.8
Using archive: /mnt/Raid/test/Backup_20090823@051500.tbz
Backup completed: 224,477,184 bytes in 100 seconds at 05:16:40 EDT
Backup started: Mon Aug 24 05:15:00 EDT 2009, MyBackup v3.1.0
Using archive: /mnt/Raid/test/Backup_20090824@051500.tbz
Removed archive: /mnt/Raid/test/Backup_20090817@051501.tbz
Backup completed: 224,307,734 bytes in 99 seconds at 05:16:39 EDT
Backup started: Tue Aug 25 05:15:00 EDT 2009, MyBackup v3.1.0
Using archive: /mnt/Raid/test/Backup_20090825@051500.tbz
Removed archive: /mnt/Raid/test/Backup_20090818@051500.tbz
Backup completed: 237,993,204 bytes in 104 seconds at 05:16:44 EDT
EOF
Thanks all
-Enjoy
fh : )_~