7stud2
(7stud --)
1
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
Thanks for help
···
--
Posted via http://www.ruby-forum.com/.
Robert_K1
(Robert K.)
2
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
···
On Sun, Sep 2, 2012 at 7:37 PM, Fosiul Alam <lists@ruby-forum.com> 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
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
7stud2
(7stud --)
3
Robert Klemme wrote in post #1074348:
/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"
Hi
but its not working
irb(main):001:0> line ='/dev/cciss/c0d11p1 /xxx/xxxxx/BD55-11
ext3 defaults,noatime,nodiratime 1 0'
=> "/dev/cciss/c0d11p1 /xxx/xxxx/BD55-11 ext3
defaults,noatime,nodiratime 1 0"
irb(main):002:0> line[%r{US\d+(?=-\d$)}]
=> nil
···
On Sun, Sep 2, 2012 at 7:37 PM, Fosiul Alam <lists@ruby-forum.com> > wrote:
--
Posted via http://www.ruby-forum.com/\.
That is working perfectly. There is no "US" anywhere in your string.
···
On Sep 2, 2012, at 14:23 , Fosiul Alam <lists@ruby-forum.com> wrote:
irb(main):001:0> line ='/dev/cciss/c0d11p1 /xxx/xxxxx/BD55-11
ext3 defaults,noatime,nodiratime 1 0'
=> "/dev/cciss/c0d11p1 /xxx/xxxx/BD55-11 ext3
defaults,noatime,nodiratime 1 0"
irb(main):002:0> line[%r{US\d+(?=-\d$)}]
=> nil
Robert_K1
(Robert K.)
5
Also the line has a completely different structure from what was
presented in the first posting of this thread.
Cheers
robert
···
On Sun, Sep 2, 2012 at 11:30 PM, Ryan Davis <ryand-ruby@zenspider.com> wrote:
On Sep 2, 2012, at 14:23 , Fosiul Alam <lists@ruby-forum.com> wrote:
irb(main):001:0> line ='/dev/cciss/c0d11p1 /xxx/xxxxx/BD55-11
ext3 defaults,noatime,nodiratime 1 0'
=> "/dev/cciss/c0d11p1 /xxx/xxxx/BD55-11 ext3
defaults,noatime,nodiratime 1 0"
irb(main):002:0> line[%r{US\d+(?=-\d$)}]
=> nil
That is working perfectly. There is no "US" anywhere in your string.
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/