Re: Split file by contents
- From: Chill Out <chillyreception@xxxxxxxxxxx>
- Date: Wed, 27 Sep 2006 19:07:30 GMT
On Wed, 27 Sep 2006 08:51:27 -0700, howa wrote for everyone to trash:
Davide Bianchi
On 2006-09-27, howa <howachen@xxxxxxxxx> wrote:
how to split a large XML file without a XML parser (since a few GB
data)
use ed:
ed - -s yourfilenamehere <<EOF > /dev/null 1
/^<book>$/
.,/^<\/book>$/w newfilenamehere
q
EOF
man ed for more info
Note: not tested.
Davide
--
Security-wise, NT is a server with a "Kick me" sign taped to it. --Peter
Gutmann
Hello, as my file is very large, so use of `sed` is better ?
Sed would work. Man sed,
http://www.cornerstonemag.com/sed/
$ sed -f/home/programs/sedfileused.ans /home/file-used
# sedfileused.ans
# sed script to delete a block if /regex/ matches inside it
:t
/\<book\/,/\/\<boo\>/ {
# For each line between these block markers..
/\<book\>/!{ # If we are not at the /end/ marker
$!{ # nor the last line of the file,
N; # add the Next line to the pattern space bt
} # and branch (loop back) to the :t label.
} # This line matches the /end/ marker.
/matched/d; # If /regex/ matches, delete the block.
} # Otherwise, the block will be printed.
#---end of script---
.
- References:
- Split file by contents
- From: howa
- Re: Split file by contents
- From: howa
- Split file by contents
- Prev by Date: Re: sudo with my aliases
- Next by Date: Re: HP All In One Printer Scanner Copier
- Previous by thread: Re: Split file by contents
- Next by thread: Can Linux set Maximum directory size?
- Index(es):