you can use xargs to get rid of that whitespace in the protocol declaration:
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 # SEPARATE SERVICE VARIABLES PROTOCOL=`echo $SERVICE | xargs | $CUT -f1 -d","` PORT=`echo $SERVICE | $CUT -f2 -d","` MESSAGE=`echo $SERVICE | $CUT -f3 -d","` done doza -----Original Message----- From: [EMAIL PROTECTED] [mailto:redhat-list-admin@;redhat.com]On Behalf Of Chad Skinner Sent: Monday, November 04, 2002 5:32 PM To: redhat-list Subject: Bash Script Question Is there a way in a bash script to trim the spaces from the front and end of a variable I have a script that contains the following variable definition BLOCKED_SERVICES="tcp,111,Sun RPC;\ udp,111,Sun RPC;\ tcp,443,Microsoft DS;\ udp,443,Microsoft DS" I am wondering what the simplest method of extracting each of the three elements from each line of the variable. In otherwords, each line is a PROTOCOL, PORT_RANGE, and DESCRIPTION. I have tried a for loop in bash similar to the following. IFS=";" for SERVICE in $BLOCKED_SERVICES do # SEPARATE SERVICE VARIABLES PROTOCOL=`echo $SERVICE | $CUT -f1 -d","` PORT=`echo $SERVICE | $CUT -f2 -d","` MESSAGE=`echo $SERVICE | $CUT -f3 -d","` The problem is that this gives the protocol with the leading spaces and I need to get rid of them. Does anyone know how to do this or have a better solution. Thanks, Chad -- redhat-list mailing list unsubscribe mailto:redhat-list-request@;redhat.com?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list -- redhat-list mailing list unsubscribe mailto:redhat-list-request@;redhat.com?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list