Prev: crontab environment problem
Next: print head and tail
From: rvaede on 6 May 2010 15:24 How can I extract the number from this line? <process_id>25752</process_id> I want to extract "25752" regards
From: Kenny McCormack on 6 May 2010 15:37 In article <b67ec6d1-245f-4e01-a71a-23bd5785d696(a)o11g2000yqj.googlegroups.com>, rvaede <rvaedex23(a)gmail.com> wrote: >How can I extract the number from this line? > ><process_id>25752</process_id> > >I want to extract "25752" > >regards Look at it. See how there are a bunch of characters before the number. Then, there is a sequence of digits - you look at that, and see it there. So, there you have it: 25752 -- > No, I haven't, that's why I'm asking questions. If you won't help me, > why don't you just go find your lost manhood elsewhere. CLC in a nutshell.
From: David W. Hodgins on 6 May 2010 15:40 On Thu, 06 May 2010 15:24:04 -0400, rvaede <rvaedex23(a)gmail.com> wrote: > How can I extract the number from this line? > <process_id>25752</process_id> #!/bin/bash String="<process_id>25752</process_id>" Tail="${String#*>}" # strip upto and including first > Number="${Tail%%<*}" # strip first < and everything after it echo "Number=$Number" Regards, Dave Hodgins -- Change nomail.afraid.org to ody.ca to reply by email. (nomail.afraid.org has been set up specifically for use in usenet. Feel free to use it yourself.)
From: Ed Morton on 6 May 2010 15:46 On 5/6/2010 2:24 PM, rvaede wrote: > How can I extract the number from this line? > > <process_id>25752</process_id> > > I want to extract "25752" > > regards There are many ways. Here's one that may or may not work with your shell: $ x="<process_id>25752</process_id>" $ echo "${x//[^[:digit:]]/}" 25752 Ed.
From: rvaede on 6 May 2010 17:39
On May 6, 3:46 pm, Ed Morton <mortons...(a)gmail.com> wrote: > On 5/6/2010 2:24 PM, rvaede wrote: > > > How can I extract the number from this line? > > > <process_id>25752</process_id> > > > I want to extract "25752" > > > regards > > There are many ways. Here's one that may or may not work with your shell: > > $ x="<process_id>25752</process_id>" > $ echo "${x//[^[:digit:]]/}" > 25752 > > Ed. Thank you. |