Any tutorials or guides that would help me learn to write linux scripts?

NaOH

Diamond Member
Mar 2, 2006
5,015
0
0
Been using ubuntu dapper and edgy for a while and love it (freeware ftw). I just wish I had more experience with it. I know all the basic terminal commands and can find fixes online that other people came up with (like disabling shift+backspace to log you out instantly). I just kind of wish I could customize it to my own liking myself. Anything I should read?
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
If you check out the guides a 'The Linux Documentation Project' you can find some good guides. In paticular a beginner's guide to the bash shell and another aimed at advanced bash scripting.

That will get you started with shell scripting. You would be able to do things like write scripts to pull files off of websites, or zip up directories, or unzip directories of zip files and any sort of common task that would normally require a lot of repetative typing or clicking. That sort of stuff.

Shell scripting is used in adminstrative stuff like that. Also it's used for writing 'init' scripts that are responsable for the startup and shutdown of your system and various services and such.

Next level above that would involve a more 'serious' scripting language such as perl or python. Python is kinda interesting to me since it's used in everything from scripting similar to shell scripts to writing web applications and video games and is typically considured very easy to learn, probably the quickest practical language to get started in. check that stuff out at python.org if your interested.

Otherwise on TLDP has guides explaining the directory layout and guides to getting more hands on with Linux and such.

Seems to me like a good place to do some reading.
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
learn some shell (not much, some basic loops is the most you need to know) then move on to a better scripting language. Perl is very nice, as it is portable (mostly) between platforms. I run/write on linux and windows. THe problem with writing on windows is that they don't offer a decent text editor. I installed VI for windows (simple stuff/minor edits) and gvim (major stuff, has the colored syntax stuff)
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: nweaver
learn some shell (not much, some basic loops is the most you need to know) then move on to a better scripting language. Perl is very nice, as it is portable (mostly) between platforms. I run/write on linux and windows. THe problem with writing on windows is that they don't offer a decent text editor. I installed VI for windows (simple stuff/minor edits) and gvim (major stuff, has the colored syntax stuff)

Check out notepad2.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: nweaver
learn some shell (not much, some basic loops is the most you need to know) then move on to a better scripting language. Perl is very nice, as it is portable (mostly) between platforms. I run/write on linux and windows. THe problem with writing on windows is that they don't offer a decent text editor. I installed VI for windows (simple stuff/minor edits) and gvim (major stuff, has the colored syntax stuff)

Xemacs works just fine. ;)
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
gvim on windows works fine, and I actually use winVI a TON (notepad is crap)

not that it matters, as MOST of my work is done in plain old VIM in linux.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Btw, I just picked up the 2nd edition of the Pragmatic Programmer's guide to Ruby. Ruby is a fairly new scripting language that has roots in Perl, Python, and Smalltalk, for those that don't know. So far, me likey.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: n0cmonkey
Originally posted by: nweaver
learn some shell (not much, some basic loops is the most you need to know) then move on to a better scripting language. Perl is very nice, as it is portable (mostly) between platforms. I run/write on linux and windows. THe problem with writing on windows is that they don't offer a decent text editor. I installed VI for windows (simple stuff/minor edits) and gvim (major stuff, has the colored syntax stuff)

Xemacs works just fine. ;)

Actually over the last thanksgiving weekend I spent the downtimes mucking around trying to learn how to use Emacs.

Debian unstable has some emacs-snapshot package which is the new Emacs22. Even has a GTK version now. So I've been trying to learn on that.

The thing I like about emacs is that you can do the alt-x (or meta-x, which in my ibook doesn't matter) and then you can have commands you just type in, with nice tab autocomplete and such.

The things that are a bit cofusing still is the whole buffer thing, which I think I have figured out now, and the fact that when I am not paying attention I still do the hit-esc-and-nail-5-or-6-characters vi-style key clobering which invariably does something horrible to the file I am editing.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: drag
Actually over the last thanksgiving weekend I spent the downtimes mucking around trying to learn how to use Emacs.

Debian unstable has some emacs-snapshot package which is the new Emacs22. Even has a GTK version now. So I've been trying to learn on that.

The thing I like about emacs is that you can do the alt-x (or meta-x, which in my ibook doesn't matter) and then you can have commands you just type in, with nice tab autocomplete and such.

The things that are a bit cofusing still is the whole buffer thing, which I think I have figured out now, and the fact that when I am not paying attention I still do the hit-esc-and-nail-5-or-6-characters vi-style key clobering which invariably does something horrible to the file I am editing.

My brain is still mostly in vi mode, but I'm working on it. Slowly. :p
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
Isn't EMACS slowly turning into it's own OS ;)

I don't do enough to require anything more then vim, as I just write short (sub 100-200 line) scripts for various tasks, and modify config files.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: nweaver
Isn't EMACS slowly turning into it's own OS ;)

I don't do enough to require anything more then vim, as I just write short (sub 100-200 line) scripts for various tasks, and modify config files.

On my Linux system, without X support it's 3.9MB. I generally use mg on my OpenBSD machines when I can, and it's only 116K (on my zaurus anyways).
 

Darkstar757

Diamond Member
Feb 1, 2003
3,190
6
81
I perfer vi over emacs any day. Its just that I know no matter what flavor of Unix-Linux I sit in front of vi will be there.

 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Darkstar757
I perfer vi over emacs any day. Its just that I know no matter what flavor of Unix-Linux I sit in front of vi will be there.

Except sometimes it's vim. :confused:

;)
 

AtlantaBob

Golden Member
Jun 16, 2004
1,034
0
0
I'm a relative newcomer to Linux as well, and have been doing quite a bit of shell scripting (and perl and python programming lately). My general suggestion is to try and set yourself up with a small problem, and just use Google (and the great references listed above) to find out more about individual commands. You really feel that you can do something when you can string a few piped commands together and produce the equivalent of a program that would have taken a few hours to write using a .net language in Windows.