Find the answer to your Linux question:
Results 1 to 4 of 4
Pathetically simple question for you folks, but I'm still learning. After you read it and have a giggle, what is the correct verdict? For an internal linux command to execute ...
  1. #1
    Just Joined! user.1's Avatar
    Join Date
    Apr 2008
    Location
    Melbourne, Victoria
    Posts
    2

    Correct command execution syntax.

    Pathetically simple question for you folks, but I'm still learning.
    After you read it and have a giggle, what is the correct verdict?

    For an internal linux command to execute inside a script do we just enter the command on it's own:

    # this is the script
    clear
    date
    __________________________________________

    Or is it more like this:

    # this is the script
    clear
    echo $date


    I don't have a working linux at home so I can't find out for myself.
    And google produced everything except what I wanted to know.

  2. #2
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    The first script works fine for me and the second does not display anything.

  3. #3
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by user.1 View Post
    For an internal linux command to execute inside a script do we just enter the command on it's own:

    # this is the script
    clear
    date
    __________________________________________

    Or is it more like this:

    # this is the script
    clear
    echo $date
    It depends on what you intend to do. Both scripts are correct if you look at the syntax (if you except the lack of the shabang on the first line).

    The first one, issues the command "clear", and then the command "date".

    The second one issues the command "clear", and then it echoes the contents of the variable called "date", which might be empty (so it will not output anything at all).

  4. #4
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Indeed. Here's the cool thing:

    A Bash script is simply a series of commands that Bash understands. Any script could be entered on the commandline, and Bash would understand it perfectly.

    In the commandline, how do you run the command "date"? You type "date". How do you print out the value of the variable $date? "echo $date".

    And so on, so forth.
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

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