On Mon, Feb 13, 2012 at 10:03 AM, lynn <lynn@steve-ss.com> wrote:
Hi Thanks for the input everyone. It's helped me get started. I should have been more specific. I've narrowed down the task to getting just the first number in a string _but_ the output comes from the wbinfo command e.g.
wbinfo -i lynn CACTUS\lynn:*:3000002:100::/home/CACTUS/lynn2:/bin/bash
I want to extract the 3000002
I've narrowed it down to this:
#!/bin/bash str=$(wbinfo -i $1) echo $str | sed -r 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/'
which gives 3000004. Good.
But if the user is called lynn2, it gives 2
So the problem comes down to: how to get the first number in the string _after_ the *: sequence
(This would work for wbinfo --group-info too as it is the same format) Thanks, L x
It would appear that the field in the wbinfo output you want to extract has a colon before and after it? Hence can't you use ... wbinfo -i lynn | awk -F":" '{print $3}' Regards Tim -- Tim Hempstead thempstead@gmail.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org