Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はこの .xml ファイルを持っています:
<docs> <doc> Some text </doc> <doc> here some </doc> <doc> text here </doc> </docs>
テキスト部分のみを取得するために csplit を使用しようとしています。これが私が思いついたものです。
$ csplit docs.xml '%^<docs>%1' '/^<\/doc/1' '{*}'
含まれているようなファイル構造の場合は、より便利な方法でコンテンツを抽出するgrep -v "^<" xかcat x|sed -e 's/<[^>]*>//g'|grep -v '^$'、以下のコメントに基づいて csplit の方法でコンテンツを抽出できます。
grep -v "^<" x
cat x|sed -e 's/<[^>]*>//g'|grep -v '^$'
cat doc.xml | egrep -v '<?xml version="1.0" \?>|<docs>|</docs>' | csplit -q -z - '/<doc/' '{*}' --prefix=out-