truncating a variable, sh enviroment - OS2

This is a discussion on truncating a variable, sh enviroment - OS2 ; I'm wondering if there is a simple way to truncate a variable, preferably in an sh script or makefile (gnu). eg changing $foo=longname to $foo=longn. Seems there should be a simple way with *nix commands Dave...

+ Reply to Thread
Results 1 to 3 of 3

Thread: truncating a variable, sh enviroment

  1. truncating a variable, sh enviroment

    I'm wondering if there is a simple way to truncate a variable,
    preferably in an sh script or makefile (gnu). eg changing $foo=longname
    to $foo=longn.
    Seems there should be a simple way with *nix commands
    Dave


  2. Re: truncating a variable, sh enviroment

    On Fri, 30 Nov 2007 18:27:35 UTC in comp.os.os2.programmer.misc, Dave Yeo
    wrote:

    > I'm wondering if there is a simple way to truncate a variable,
    > preferably in an sh script or makefile (gnu). eg changing $foo=longname
    > to $foo=longn.
    > Seems there should be a simple way with *nix commands


    [H:\]bash
    # export FOO=12345678
    # echo $FOO
    12345678
    # FOO=`echo $FOO | cut -c1-7`
    # echo $FOO
    1234567

    --
    Trevor Hemsley, Brighton, UK
    Trevor dot Hemsley at ntlworld dot com

  3. Re: truncating a variable, sh enviroment

    On 11/30/07 11:22 am, Trevor Hemsley wrote:
    > On Fri, 30 Nov 2007 18:27:35 UTC in comp.os.os2.programmer.misc, Dave Yeo
    > wrote:
    >
    >> I'm wondering if there is a simple way to truncate a variable,
    >> preferably in an sh script or makefile (gnu). eg changing $foo=longname
    >> to $foo=longn.
    >> Seems there should be a simple way with *nix commands

    >
    > [H:\]bash
    > # export FOO=12345678
    > # echo $FOO
    > 12345678
    > # FOO=`echo $FOO | cut -c1-7`
    > # echo $FOO
    > 1234567
    >

    Ok, this works once I realized that those are back quotes. Previously
    stared at the cut man page for quite a while without this jumping out at
    me
    Thanks
    Dave


+ Reply to Thread