Find the answer to your Linux question:
Results 1 to 7 of 7
OK I put- set i = hello which according to all I've read should make a variable called i containing 'hello'. Yet when I put in echo $i I get ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2005
    Posts
    3

    The really simple things always get me


    OK I put-

    set i = hello

    which according to all I've read should make a variable called i containing 'hello'.

    Yet when I put in

    echo $i

    I get just a blank line.
    Does anyone know what I'm doing wrong? This little thing is really getting in my way of doing what I need to do.

    I'm using SSH secure shell.

  2. #2
    Linux Guru fingal's Avatar
    Join Date
    Jul 2003
    Location
    Birmingham - UK
    Posts
    1,539
    I don't script, but everyone usually recommends this. I suspect you don't need the 'set' statement.

    I think when you say 'secure shell' you might mean the sh shell ... I'm assuming this is a shell script you are writing.
    I am always doing that which I can not do, in order that I may learn how to do it. - Pablo Picasso

  3. #3
    Just Joined!
    Join Date
    Nov 2005
    Posts
    3
    ah...got it, not supposed to have spaces...
    But then how do you use such commands?
    if I was to do in a script
    mv * $i
    to move all files into hello it comes up with a strange error about mv being a missing file argument?
    I had previously done read i. What is it if not read?

  4. #4
    Linux Guru fingal's Avatar
    Join Date
    Jul 2003
    Location
    Birmingham - UK
    Posts
    1,539
    Someone else will handle this for you, but *be careful* using the mv command. You might consider using cp instead to copy files (at least until you are sure that things work).

    mv can alter your file names beyond recognition.
    I am always doing that which I can not do, in order that I may learn how to do it. - Pablo Picasso

  5. #5
    Just Joined!
    Join Date
    Nov 2005
    Posts
    3
    Having tried other things I think my problems come down to the $read command.
    It never works.
    I set them and they load into scripts as blanks or not at all.

  6. #6
    Banned CodeRoot's Avatar
    Join Date
    Sep 2005
    Posts
    567
    The first bit of information that would be good for us to know is, what shell environment or scripting language are you using? 'set i = hello' is a perfectly good 'csh'/'tcsh' statement, but will not work in 'bash' or 'perl'... (I am guessing you are writing a 'bash' script?)

  7. #7
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Quote Originally Posted by Boriss
    Having tried other things I think my problems come down to the $read command.
    It never works.
    I set them and they load into scripts as blanks or not at all.
    read always works for me. Can you post a snippet of a script that you think isn't doing what you've coded it to do?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •