I'm not that familiar with Linux so I'm having trouble converting the following command into a relatively short Linux version.
FOR /F "eol=; tokens=2,2 delims==" %i IN ('findstr /i "version" test.properties') D开发者_开发技巧O
When googling I seem to always stumble upon overly long solutions.
I believe it is equivalent to:
for i in $(grep -i "version" test.properties | cut -d= -f2)
do
echo $i
done
sed -ne 's/^ *version *= *\([^;]*\).*/\1/p' < test.properties | while read i; do ... done
Using sed
to search the required line and parse out the value at the same time and while read to keep line separation.
Next time, show a sample of your test.properties file so that others won't have to guess how it looks like. Also, show your desired output as well.
awk 'BEGIN{IGNORECASE=1;FS="="}/version/{print $2;exit}' test.properties
精彩评论