1 Reply Latest reply on Mar 17, 2011 2:40 PM by David Maughan

    Substrings in NSH

    David Maughan

      How do you extract a substring in NSH?  I tried ${VAR:START:LENGTH} but I just get an "invalid modifier" error.

        • 1. Re: Substrings in NSH
          David Maughan

          Ok, I found a way to do what I wanted, but I'd be interested to know of other ways to extract a substring.  Here's my expample:


               MYOS="Server 2008 R2 x64";

               OSVER=`echo ${MYOS} | awk '{ print $2 }'`;

               OSARCH=`echo ${MYOS} | awk '{ print substr($0,length($0)-2) }'`;


          This returns 2008 for OSVER and x64 for OSARCH as expected.