Command xproperties


xproperties Manage a Java Properties file


xproperties [ serialization options ] [options]

-in fileLoad a Properties file in text form
-inxml fileLoad a Properties file in xml form
-text Output properties in text form to stdout
-xmlOutput properties in xml form to stdout
-d,-delete varDelete a variable from the properties
-a,-add var=valueAdd (or replace) a variable (name "var", value "value") to the properties
-commentAppend or update the comment
-v,-var varprint out the value of a variable (cannot be intermixed with -text or -xml)

Supports the standard [ serialization options ]


xproperties can be used to create new properties files, transform files from text to xml form, add, delete and print property values.

xproperties creates a Java Properties object in memory, then optionaly loads values from a file (in text or xml form), optional adds or updates the properties then prints the resultant properties file in either text or xml form.
The text and XML forms are as specified (and implemented) by the Java java.util.Properties object
if one or more -v (or -var) options are specified then instead of serializeing the entire resultant properties file then one or more values from the (possibly edited) properties file are output followed by a newline.

If a input file is specified as "-" then stdin is used.
If neither -v, -text or -xml is specified then -xml is presumed.


Create a new properties file in text form with initial contents
xproperties -text -a var1="Value 1" -add var2="Value 2"

Produces this output
#Sat Nov 14 12:42:24 EST 2009
var2=Value 2
var1=Value 1

Convert the above property file to xml form
xproperties -in


<!DOCTYPE properties SYSTEM "" []>
<properties version="1.0">
   <entry key="var2">Value 2</entry>
   <entry key="var1">Value 1</entry>

Print out the value of var2 from the above xml format
xproperties -inxml prop.xml -v var2

Value 2

Using with tie

xproperties output can be easily referenced using the tie command


Input file a text formated properties file

This command
PROPS=$<(xproperties -in
tie PROPS './/entry[@key = $_ ]/string()'

echo ${PROPS:login}


Return Value

Returns 0 if the command executed successfully, 1 if there was an error.

There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki