tests/ds_unselect_rules.sh
#!/bin/bash if [ ! -f "$1" ] || [ ! -f "$2" ]; thenDouble quote to prevent globbing and word splitting.
Don't use variables in the printf format string. Use printf "..%s.." "$foo". printf "Usage: $(basename $0) <DATASTREAM> <UNSELECT_LIST_FILE>Copies the DATASTREAM file to /tmp and unselects the rules listedin the UNSELECT_LIST_FILE from the /tmp/DATASTREAM file.\n" exit 1fiDS=$1UNSELECT_LIST=$2 printf 'Copying %s file to /tmp\n' "$DS"Double quote to prevent globbing and word splitting.cp $DS /tmp || exit 1Double quote to prevent globbing and word splitting.DS="/tmp/$(basename $DS)" printf 'Unselecting rules listed in the %s from the %s\n' "$UNSELECT_LIST" "$DS"Double quote to prevent globbing and word splitting.
To read lines rather than words, pipe/redirect to a 'while read' loop.for rule in $(cat $UNSELECT_LIST); doDouble quote to prevent globbing and word splitting. sed -i "/<.*Rule.*id=\"$rule/s/selected=\"true\"/selected=\"false\"/g" $DS || exit 1Double quote to prevent globbing and word splitting. sed -i "/<.*select.*idref=\"$rule/s/selected=\"true\"/selected=\"false\"/g" $DS || exit 1doneprintf "Done\n"