How do I get value of variable from file using shell script?
问题 There is a file post_check.ini I need the value set for: Max_value=2 How would I get the value 2 from Max_value ? 回答1: try grep -Po '(?<=Max_value=).*' post_check.ini 回答2: Max_value=$(sed -n '/^Max_value=\([0-9]*\)$/s//\1/p' post_check.ini) 回答3: I recommend using crudini which is a dedicated tool to manipulate ini files from shell value=$(crudini --get /usr/post_check.ini section Max_value) Details on usage and download at: http://www.pixelbeat.org/programs/crudini/ 回答4: You might find it