..
Extract keys and values from Java properties files
Open a Terminal window and type the command below:
cut -d = -f 1 filename.properties | tr ‘,’ ‘n’ | sed "/^$/d" > output_keys.txt
Original file:
keyname.url=https://www.example.com/foo/#
keyname.viewdetails=View details...
keyname.vieweventlabel=View Event
keyname.buttonViewEvent.src=http://www.example.com/images/buttonViewEvent.png
keyname.local.src=<a href=http://www.example.com/>Test</a>
Output:
keyname.url keyname.viewdetails keyname.vieweventlabel keyname.buttonViewEvent.src keyname.local.src
To extract values, type the following command in Terminal:
grep 'keyname' filename.properties | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' > output_values.txt
Output:
https://www.example.com/foo/# View details... View Event http://www.example.com/images/buttonViewEvent.png <a href=http://www.example.com/>Test</a>
The output of both files can be pasted in Numbers in separate columns and exported as a CSV file.