On Sun, Sep 2, 2012 at 7:37 PM, Fosiul Alam <[email protected]> wrote:
> HI
>
>
> df -h
> Filesystem Size Used Avail Use% Mounted on
>
> /dev/cciss/c0d1p1 1.8T 88M 1.7T 1% /xxx/xxxx/BD55-1
> /dev/cciss/c0d2p1 1.8T 88M 1.7T 1% /xxx/xxxx/BD55-2
> /dev/cciss/c0d3p1 1.8T 88M 1.7T 1% /xxx/xxxx/BD55-3
> /dev/cciss/c0d4p1 1.8T 88M 1.7T 1% /xxx/xxxx/BD55-4
> /dev/cciss/c0d5p1 1.8T 88M 1.7T 1% /xxx/xxxx/BD55-5
>
> Some how i jus want to get whats the code for the cluster
> which is BD55
>
>
> now /xxx/xxxx/ is same for every line and after US55(this value
> different for every server) there would be a - (BD55-)
>
> I would be really help full if any one can help me
One way would be to read this line by line and use Regexp
e.g.
irb(main):001:0> line = '/dev/cciss/c0d5p1 1.8T 88M 1.7T 1%
/xxx/xxxx/BD55-5'
=> "/dev/cciss/c0d5p1 1.8T 88M 1.7T 1% /xxx/xxxx/BD55-5"
irb(main):002:0> line[%r{BD\d+(?=-\d$)}]
=> "BD55"
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en