1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

How to save a shell script

Discussion in 'Linux and Unix' started by new_techie, Nov 20, 2007.

Thread Status:
Not open for further replies.
  1. new_techie

    new_techie Thread Starter

    Nov 20, 2007

    So I'm new to programming in Linux/Unix. Can anyone tell me how I can write a shell script and then save it? As in write a little programme and then be able to execute it whenever I like? I'm stating the obvious by saying I don't have to type the whole thing each time. Does anyone know a good website for learning how to write scripts?

    Thanks all!
  2. RobLinux


    Nov 7, 2007
    $ cat > ~/bin/myscript

    # My first script
    echo Foo bah!
    $ chmod +x !$

    To edit in terminal there's usually a simple editor like nano installed, or you can use GUI text editor (avoid word processor as they do dumb things to programs). If you're a touch typist, then vi(1) is the best so long as you don't mind modes and putting in a little effort to learn it, emacs(1) and most other editors like <CNTRL> and <ALT> codes for commands.

    Just go to http://tldp.org/ there's Guides, read "Intro to Linux", "Bash Guid for Beginners", "Command Line Tools" and only then "Advanced Bash-Scripting".

    Ubuntu's using dash, rather than bash during boot up for greater speed, so actually writing standard Bourne shell and avoiding Bash specific extensions might be an idea. dash is the BSD 4.4 shell, and like much BSD 4.4 stuff had excellent re-implementations of trad UNIX stuff. It's usually not too hard to write stuff portably, or convert from Bash-ism to a standard Bourne script.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Similar Threads - save shell script
  1. ItsBeagle
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/653929