Hi,
Does this have to be done with sed or awk?
This does what you want, but no sed or awk is used:
Code:
#!/bin/bash
# test string used:
i="-pabc.par -sXYZ:123 -cZZ"
# start with nullified variables
P=""
S=""
S=""
# parse contents of i one at the time (if any):
for THIS in ${i}
do
# check to see if first 2 characters match.
case ${THIS} in
-p*) P=${THIS:2} ;; # a match on -p , remove first 2 characters
-s*) S=${THIS:2} ;;
-c*) C=${THIS:2} ;;
esac
done
# print variables:
echo "P: ${P}"
echo "S: ${S}"
echo "C: ${C}"
exit 0
A sed or awk solution is probably possible, but this seems to be one of the simpler ways of doing it (my 2c, that is

).
Anyway, hope this helps.