Unix/Linux Forum: String manipulations in scripting - Unix/Linux Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

String manipulations in scripting Rate Topic: -----

#1 User is offline   peru Icon

  • User Level: 1/10
  • Pip
  • Group: Members
  • Posts: 18
  • Joined: 20-August 08

Posted 08 October 2008 - 11:02 AM

Hi,

I have a variable

ARGS=-start,0x7fffffffffffff1f,0x0000000000000000,{RAW}.*

I would like to extract the following string 0x7fffffffffffff1f,0x0000000000000000,{RAW}.* and further place the string in three different variables as follows

ARGS1=0x7fffffffffffff1f
ARGS2=0x0000000000000000
ARGS3={RAW}.*

P.S: I would wish to extract the string specifiying the starting character as '0'.

Regards
Peru
0

#2 User is offline   radoulov Icon

  • User Level: 2/10
  • PipPip
  • Group: Members
  • Posts: 25
  • Joined: 17-May 07

Posted 08 October 2008 - 01:05 PM

Using comma as a separator:

$ ARGS="-start,0x7fffffffffffff1f,0x0000000000000000,{RAW}.*"
$ ifs="$IFS"; set -f; IFS=,;set -- $ARGS; set +f; IFS="$ifs"
$ ARGS1="$2" ARGS2="$3" ARGS3="$4"
$ printf "%s\n" "$ARGS1" "$ARGS2" "$ARGS3"
0x7fffffffffffff1f
0x0000000000000000
{RAW}.*

0

#3 User is offline   peru Icon

  • User Level: 1/10
  • Pip
  • Group: Members
  • Posts: 18
  • Joined: 20-August 08

Posted 10 October 2008 - 12:48 PM

Thanks :D
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Cambridge Plus :: Cambridgeshire Steam Rally :: Electronic Design Bedfordshire :: British Bike Piston Rings
Unix Man Pages / Linux Man Pages :: HiFi Forum :: A14 Comments :: UNIX/Linux Forum Archives