On Mon, 4 Nov 2002, Chad Skinner wrote: > Is there a way in a bash script to trim the spaces from the front and end of > a variable
Not the way you're doing it. The easiest thing to do is to change your data representation, rather than spending a lot of time trying to strip whitespace. Try: BLOCKED_SERVICES="tcp,111,Sun RPC:udp,111,Sun RPC:tcp,443,Microsoft DS:udp,443,Microsoft DS" IFS=: for SERVICE in $BLOCKED_SERVICES; do PROTOCOL=$(cut -d, -f1 <(echo $SERVICE)) PORT=$(cut -d, -f2 <(echo $SERVICE)) MESSAGE="$(cut -d, -f3 <(echo $SERVICE))" for DATA in PROTOCOL PORT MESSAGE; do echo "$DATA=${!DATA}" done echo done -- "Whenever I feel blue, I start breathing again." - Unknown -- redhat-list mailing list unsubscribe mailto:redhat-list-request@;redhat.com?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list