Jun 7, 2007 #1 jtanner Technical User Feb 18, 2007 39 US Hello, In a Bourne shell script I have a variable length string that is enclosed in parenthesis. Examples Code: echo "$CONN1" (2msec) echo "$CONN2" (10msec) echo "$CONN3" (100msec) How can I get ride of the parenthesis? Thanks, JT
Hello, In a Bourne shell script I have a variable length string that is enclosed in parenthesis. Examples Code: echo "$CONN1" (2msec) echo "$CONN2" (10msec) echo "$CONN3" (100msec) How can I get ride of the parenthesis? Thanks, JT
Jun 7, 2007 #2 aigles Technical User Sep 20, 2001 464 FR You can use tr : Code: echo "$CONN1" | tr -d '()' Jean-Pierre. Upvote 0 Downvote
Jun 7, 2007 #3 sbrews Technical User Jun 11, 2003 413 US I'm assuming that (2msec) is what is contained in variable CONN1. Based on that assumption, this will remove the parens: Code: CONN1=`echo $CONN1| tr -d '()'` echo $CONN1 2msec Add a little color to your PUTTY terminal: faq52-6627 Upvote 0 Downvote
I'm assuming that (2msec) is what is contained in variable CONN1. Based on that assumption, this will remove the parens: Code: CONN1=`echo $CONN1| tr -d '()'` echo $CONN1 2msec Add a little color to your PUTTY terminal: faq52-6627
Jun 7, 2007 #4 sbrews Technical User Jun 11, 2003 413 US It appears that aigles is faster on the keyboard than me. Add a little color to your PUTTY terminal: faq52-6627 Upvote 0 Downvote
It appears that aigles is faster on the keyboard than me. Add a little color to your PUTTY terminal: faq52-6627
Jun 7, 2007 #5 PHV MIS Nov 8, 2002 53,708 FR The good old legacy Bourne shell... what about this ? Code: expr "$CONN1" : '(\(.*\))' Hope This Helps, PH. FAQ219-2884 FAQ181-2886 Upvote 0 Downvote
The good old legacy Bourne shell... what about this ? Code: expr "$CONN1" : '(\(.*\))' Hope This Helps, PH. FAQ219-2884 FAQ181-2886
Jun 7, 2007 #6 p5wizard IS-IT--Management Apr 18, 2005 3,165 BE With sed: Code: CONN1=$(echo "${CONN1}"|sed 's/[()]//g') or Code: CONN1=`echo "${CONN1}"|sed 's/[()]//g'` HTH, p5wizard Upvote 0 Downvote
With sed: Code: CONN1=$(echo "${CONN1}"|sed 's/[()]//g') or Code: CONN1=`echo "${CONN1}"|sed 's/[()]//g'` HTH, p5wizard
Jun 8, 2007 Thread starter #7 jtanner Technical User Feb 18, 2007 39 US Guys, All your suggestions were simple and brilliant. Thanks, JT Upvote 0 Downvote
Jun 8, 2007 #8 p5wizard IS-IT--Management Apr 18, 2005 3,165 BE Here's a less "simple" solution ;-): Code: CONN1=$(echo "${CONN1}"|fold -w1|grep -v '('|grep -v ')'|tr -d '\n') HTH, p5wizard Upvote 0 Downvote
Here's a less "simple" solution ;-): Code: CONN1=$(echo "${CONN1}"|fold -w1|grep -v '('|grep -v ')'|tr -d '\n') HTH, p5wizard