Quantcast
Channel: Active questions tagged bash+awk - Ask Ubuntu
Viewing all articles
Browse latest Browse all 102

awk -v var=$var /var/ is not working as expected

$
0
0

Portion of file:

<style:style style:name="P15" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/><style:text-properties style:font-name="open sansregular2" fo:font-size="18pt" fo:font-weight="normal" officeooo:rsid="00300000" officeooo:paragraph-rsid="00100000" style:font-size-asian="18pt" style:font-weight-asian="normal" style:font-size-complex="18pt" style:font-weight-complex="normal"/></style:style><style:style style:name="P16" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/><style:text-properties fo:color="#000000" style:font-name="open sansregular2" fo:font-size="18pt" officeooo:rsid="00050000" officeooo:paragraph-rsid="000040000" style:font-size-asian="18pt" style:font-size-complex="18pt"/></style:style><style:style style:name="P17" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/><style:text-properties fo:color="#000000" style:font-name="open sansregular" fo:font-size="18pt" officeooo:rsid="00100002" officeooo:paragraph-rsid="00100002" style:font-size-asian="18pt" style:font-size-complex="18pt"/></style:style>
awk '/\<style:style style:name="P16"/,/style:style\>/' RS='\</style:style\>' file

although probably not formed correctly, produces desired results:

<style:style style:name="P16" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/><style:text-properties fo:color="#000000" style:font-name="open sansregular2" fo:font-size="18pt" officeooo:rsid="00050000" officeooo:paragraph-rsid="000040000" style:font-size-asian="18pt" style:font-size-complex="18pt"/>

(I want the whole block, including the </style:style>, but can work with as is), however,

echo $TPNum"P16"awk -v TPNum=$TPNum '/\<style:style style:name=TPNum/,/style:style\>/' RS='\</style:style\>' file

produces no results, other than same warning: awk: warning: escape sequence `\<' treated as plain `<' awk: warning: escape sequence `\>' treated as plain `>'.I have used variables with awk before with no problems. What am I missing here, please?


Viewing all articles
Browse latest Browse all 102

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>