I have following string:ksh -x SCRIPT2.ksh $BUSSINESSDATE & PID=$!; ksh -x SCRIPT1.ksh $BUSSINESSDATE & PID=$!;I want to strip off the last word & PID=$!;. Desired result is:ksh -x SCRIPT2.ksh $BUSSINESSDATE & PID=$!; ksh -x SCRIPT1.ksh $BUSSINESSDATENote: that I do have & PID=$!; in the middle of the string, I only need to get rid of the last word which contains & PID=$!;I am using sed achieve this. But it doesn't seems to produce the expected output.sed 's/\(\& PID=\$\!\).*$//'any help would be appreciated.
Strip off word pattern at the end of string using sed
bash;command line;text processing;sed;regular expression
sed -e 's/& PID=\$\!;$//'The $ toward the end anchors it to the end of the string.