Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: How to compile bash from an editor?

  1. #1
    Join Date
    Nov 2008
    Beans
    4

    Question How to compile bash from an editor?

    Hi,

    can someone tell me how to compile bash from a text file like kate?
    I mean what is the command in the terminal once I'm in the root?

    thanks

  2. #2
    Join Date
    Jul 2007
    Beans
    228
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: How to compile bash from an editor?

    Hi. Welcome to the forums.
    I am a bit confused over your question. Do you mean to compile a program from the source code? Kindly elaborate.
    Remember: With great power comes great current squared times resistance.

  3. #3
    Join Date
    Oct 2007
    Location
    $HOME
    Beans
    631

    Re: How to compile bash from an editor?

    normally to compile bash, you would use
    configure
    make
    make install

    however if you want to compile your own program then (considering it is in c),

    gcc /path/to/source/file -o output_file_name

    other switches maybe applied as and when needed

  4. #4
    Join Date
    Nov 2008
    Beans
    128
    Distro
    Ubuntu

    Re: How to compile bash from an editor?

    If you are talking about BASH script itself, you can't compile it like like you would with a language such as C/C++. The reason for this is that it is interpreted language which gets translated into machine code at runtime.

  5. #5
    Join Date
    Nov 2007
    Location
    Okieville, USA
    Beans
    3,178
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How to compile bash from an editor?

    .bashrc is a text file that tells bash how to look and behave.
    MCP, A+/Linux+ Certified IT Technician
    System Specs | Dress up your "Super Button" FREE
    "If sometimes you can't be good, then be VERY good at being naughty!"

  6. #6
    Join Date
    Nov 2008
    Beans
    4

    Re: How to compile bash from an editor?

    I mean I wrote some bash scripts in a text file
    #!/bin/bash
    case ...

    ..
    and saved the file as .sh
    I'm looking for the comand line to comile my .sh file?
    thanks for your welcome message btw

  7. #7
    Join Date
    Aug 2007
    Location
    Kottawa, Sri Lanka
    Beans
    7,387
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How to compile bash from an editor?

    Quote Originally Posted by tennis_girl View Post
    I mean I wrote some bash scripts in a text file
    #!/bin/bash
    case ...

    ..
    and saved the file as .sh
    I'm looking for the comand line to comile my .sh file?
    thanks for your welcome message btw
    You can't compile shell scripts. You can execute them by doing:-
    Code:
    ./name-of-script.sh
    you may first want to make them executable with:-
    Code:
    chmod +x name-of-script.sh
    Think carefully before executing commands containing "rm", especially "sudo rm -rf ", if you require more information concerning this matter, read this.
    I am an experimenter, give me the most stable OS and I can make it unstable in a few hours.

    C == seriously fast == FTW!

  8. #8
    Join Date
    Nov 2008
    Beans
    4

    Re: How to compile bash from an editor?

    I would like to compile a .sh file(bash shell file)

  9. #9
    Join Date
    Nov 2008
    Beans
    128
    Distro
    Ubuntu

    Re: How to compile bash from an editor?

    You don't compile BASH script it is an interpreted language. You can execute it on the command line. You need to change it to be an executable before you run it which might be what you are asking.

    To do this, if the file is called script.sh

    Code:
    chmod 755 script.sh
    The text file is now executable.

    I'm hoping this answers your question.

  10. #10
    Join Date
    Mar 2007
    Location
    Denver, CO
    Beans
    7,958
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: How to compile bash from an editor?

    Last time on this one:

    bash shell scripts are interpreted not compiled -- hence there is no reason to compile them.

    If you want a personal .bash or .sh file, compose the file, save it, do the following:

    chmod +x <xxxxx.sh>

    Copy the file to your personal bin directory since this is in your path (you have to make the directory since its not included by default):
    mkdir -p ~/bin

    cp <shell_script_file.sh> ~/bin/<shell_script_file.sh>

    Ok now you can run the shell script from the command line by simply typing

    <shell_script_file.sh>

    NO NEED TO COMPILE!!!

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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