#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Having a problem with shift


    Hello, I made a very simple program on the vi for a homework. However, whenever I try to run it, it tells me the specific number is not valid for this command, referring to shift. It looks like this:

    count=o
    while [ $count -le 12 ]
    do
    echo "$1"
    shift
    count=`expr $count + 1`
    done

    I tried searching everywhere for an answer but no luck. Any suggestions?
    Last edited by Meatsawce; October 31st, 2012 at 12:45 PM. Reason: Error in the code
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    834
    Rep Power
    387

    Cool


    Originally Posted by Meatsawce
    ... Etc ....
    I tried searching everywhere for an answer but no luck. Any suggestions?
    Have you tried looking it up in the manual?
    man shift
    Code:
    shift
    Shift positional parameters to the left by n.
    
    Syntax
          shift [n]
    
    Options
    
       n  : The number of parameters to shift (default = 1)
    
    The positional parameters from
    n+1 ... $#
    are renamed to
    $1 ... $#-n+1
    
    Parameters represented by the numbers $# to n+1 are unset.
    
    n must be a positive number less than or equal to $#.
    
    The return status is zero unless n is greater than $# or less than zero.
    
    shift is a builtin command.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,394
    Rep Power
    1688
    Also, probably a transcription glitch ...

    count=o <-- that's a letter, not the number!
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    834
    Rep Power
    387

    Talking


    Good catch Hilaire!!!

IMN logo majestic logo threadwatch logo seochat tools logo