sh-2.05$ who
foo pts/0  Jun 19 21:50 (222-152-182-159.jetstream.xtra.co.nz)

So, I need to extract 222.152.182.159 using bash from the above string using bash scripting so I can update $CVSROOT.


MY_CURRENT_IP = $(who | cut -d( -f2 | cut -d\. -f1 | tr - \.)

The first cut picks up the open round bracket, and provides the right-hand portion.
The second cut finds the dot before jetstream, and returns the left.
The final tr converts the hyphens into dots.




Reply via email to