automate/sed_comment-uncomment_example/test-sed.sh

24 lines
693 B
Bash

CONFIG_FILE=./config.yaml
PATTERN1="contrib"
PATTERN2="non-free"
cat ${CONFIG_FILE}
echo "Uncomment:"
echo "PATTERN1: sed -i \"/${PATTERN1}/s/^#.//g\" ${CONFIG_FILE}"
sed -i "/${PATTERN1}/s/^#.//g" ${CONFIG_FILE} # (to uncomment)
echo "PATTERN2: sed -i \"/${PATTERN2}/s/^#.//g\" ${CONFIG_FILE}"
sed -i "/${PATTERN2}/s/^#.//g" ${CONFIG_FILE} # (to uncomment)
cat ${CONFIG_FILE}
echo "Comment:"
echo "sed -i \"/${PATTERN1}/s/^/# /g" ${CONFIG_FILE}\" # (to comment)
sed -i "/${PATTERN1}/s/^/# /g" ${CONFIG_FILE} # (to comment)
echo "sed -i \"/${PATTERN2}/s/^/# /g" ${CONFIG_FILE}\" # (to comment)
sed -i "/${PATTERN2}/s/^/# /g" ${CONFIG_FILE} # (to comment)
cat ${CONFIG_FILE}