Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/sbin/sh
- # Feature XML Edit in directory
- # created by ~clumsy~
- # Usage:
- # set_xml_dir.sh <directory> <file_name_pattern> <feature_name> <value_to_change_to>
- # Note: If there is any spaces in a argument, capture them in quotations e.g. 'Some String'
- # Example_1: set_xml_dir.sh /system other.xml CscFeature_IMS_EnableVoLTE False
- # Example_2: set_xml_dir.sh /system other.xml CscFeature_Common_AutoConfigurationType 'NO_DFLT, SIMBASED_OMC'
- dir=$1
- pattern=$2
- feature=$3
- value=$4
- for file in $(find $dir -name '$pattern')
- do
- lineNumber=0
- lineNumber=`sed -n "/<${feature}>.*<\/${feature}>/=" $file`
- if [ $lineNumber > 0 ] ; then
- echo "Found feature $feature in line $lineNumber and changing it to ${value}"
- sed -i "${lineNumber} c<${feature}>${value}<\/${feature}>" $file
- else
- echo "Adding feature $feature to the feature set"
- sed -i "/<\/FeatureSet>/i <${feature}>${value}<\/${feature}>" $file
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement