[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: complex shell scripts



On Wed, Sep 13, 2000 at 10:06:48AM -0400, Mark Simos wrote:
> I am looking to understand the everyday admin of unix and how people put
> together the common commands into compound/complex shell scripts.
> 
> does anybody know of a good place for samples (this is how you import
> users form a text file or some such thing)

i agree that the best way to learn is by disecting examples of other
peoples' code. so go nose around...

-	everything in /etc/init.d (on debian) is a shell script.

-	% pager `which <command>`
	if it's not binary, you'll see a shell (or sometimes perl) script
	[note that those are `backticks` and not 'apostrophes']

-	sometimes scripts are named with appropriate extensions
	(apt-get install slocate, if you need to)	
	% locate .sh
	% locate .csh
	% locate .bash
	% locate .zsh

-	for examples of pluggable modularity, see (for example) the
	ipmasq startup scripts in /etc/ipmasq/rules/
	(apt-get install ipmasq)

at the beginning of any shell script (there are hundreds if not thousands
on any linux/unix system) there's the "#!" shebang notation that points
to the particular command (shell) to interpret that file:
	#!/bin/sh
	#!/usr/bin/csh
	#!/bin/bash
	#!/usr/bin/zsh
	including
	#!/usr/local/bin/perl
(this is why the filename extension is optional -- the contents of the
file itself determine 'who' needs to 'run' it, functionally similar to
file-creator code on the mac)

to see what the syntax means, if it's not commented clearly in the
code itself, (or if you just wanna see what ELSE the 'language'
enables you to do) try
	man sh
	man csh
	man bash
	man zsh
sometimes the manpage will point you to use info to learn more...



Reply to: