help me out with subroutines - Unix

This is a discussion on help me out with subroutines - Unix ; I am trying to write a unix shell I am having trouble emulating the trim function which trims whitespaces. for example use $echo " x" this just displays x since echo trims whitespaces...

+ Reply to Thread
Results 1 to 4 of 4

Thread: help me out with subroutines

  1. help me out with subroutines

    I am trying to write a unix shell
    I am having trouble emulating the trim function which trims
    whitespaces.
    for example use
    $echo " x"
    this just displays x
    since echo trims whitespaces


  2. Re: help me out with subroutines

    > I am trying to write a unix shell

    In what language?

    > $echo " x"
    > this just displays x
    > since echo trims whitespaces


    Actually, in many shells:

    echo " x"

    Will print "x" preceded by 24 spaces. On the other hand:

    echo x

    (No quotation marks) will just print "x" at the beginning of the line.

    It's also worth mentioning that *echo* isn't trimming the whitespace
    here. The *shell* tokenizes the command line on whitespace, so the
    command that runs is really just "echo x".

    -- Lars

    --
    Lars Kellogg-Stedman <1o4ibj70m3vooae@jetable.org>
    This email address will expire on 2005-11-22.


  3. Re: help me out with subroutines

    keerthi.nightfox wrote:

    >I am trying to write a unix shell
    >I am having trouble emulating the trim function which trims
    >whitespaces.
    >for example use
    >$echo " x"
    >this just displays x
    >since echo trims whitespaces
    >
    >
    >

    check

    $echo " x" | wc -c



    --
    Thobias Vakayil
    Alcatel Development India (ADI)
    PH: 2349961/72/86 EXTN :7018

  4. Re: help me out with subroutines

    Thobias Vakayil wrote:

    > keerthi.nightfox wrote:
    >
    >> I am trying to write a unix shell
    >> I am having trouble emulating the trim function which trims
    >> whitespaces.
    >> for example use
    >> $echo " x"
    >> this just displays x since echo trims whitespaces
    >>
    >>
    >>

    > check
    >
    > $echo " x" | wc -c
    >
    >
    >

    $x=" hello"
    $echo $x
    hello
    $echo "$x"
    hello


    --
    Thobias Vakayil
    Alcatel Development India (ADI)
    PH: 2349961/72/86 EXTN :7018

+ Reply to Thread