Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Shells Bulletin
(old and very old news;-)

freshmeat.net Project details for ddclient

 
[»] ddclient
by Monarch - Jul 17th 2003 05:40:18

I had some trouble with ddclient as well. So I developed a short bash-script that updates the hosts ip-address on dyndns.org when changed:

#!/bin/bash
export LANG="default"
ipneu=`/sbin/ifconfig *interface* | grep inet | awk '{print $2}' | sed 's#addr:##g'`
set `cat /var/spool/ipalt`
ipalt=$1
if [ "$ipalt" == "$ipneu" ]
then
echo "nochg">>/var/log/dyndnslog
else
echo "updating">>/var/log/dyndnslog
echo $ipneu>/var/spool/ipalt
wget -a /var/log/dyndnslog "http://*username*:*passwd*@members.dyndns.org/nic/update?system=dyndns&hostname=*mydomain*" -O /var/log/dyndnsres
cat /var/log/dyndnsres>>/var/log/dyndnslog
fi

To configure this script replace the following words:
*interface* name of the interface to fetch the IP from i.e. ppp0
*username* username of dyndns.org-account
*passwd* password to this account
*mydomain* hostname of the accounts domain to be updated ie. mydomain.dyndns.org

now save it to a directory that's in the search path ie.: /usr/sbin/updatedyndns
set the apropiate rights to this file to make it executable. ie.: chmod 4755 /usr/sbin/updatedyndns
add a script to the ppp/ip-up.d directory to make the machine execute the script everytime a new ppp-connection is made.

This script has no error-handling but it worked best for me so far. U might have noticed that this needs wget to be installed.

--
_____ Just because you're paranoid, it don't mean they're not after you.

 

Re:My personal favorite; (Score:2)
by 26199 (577806) * on Wednesday March 10, @08:54PM (#8527893)
(http://www.davidmorgan.org/)
:(){ :|:&};:

It reads... define function ':' as follows: pipe the output from function ':' into function ':' -- do that in the background (ie fork). Call the function ':'.

I had no idea how it worked, either, but I looked it up :-)
My favourite shell script... (Score:2)
by cperciva (102828) on Wednesday March 10, @03:09PM (#8524266)
(http://www.daemonology.net/)
... is FreeBSD Update [daemonology.net]. 700 lines of shell code to fetch, install, and rollback security updates to an entire operating system.

 

Tab completion (Score:3, Informative)
by Spy Hunter (317220) on Wednesday March 10, @03:03PM (#8524210)
(http://www.xwt.org/ | Last Journal: Saturday February 23, @04:33AM)
In Debian, the Bash package comes with a totally awesome collection of customized tab completions. For some reason, they are not turned on by default. To turn them on in a single account, you can put the line "source /etc/bash_completion" in your ~/.bashrc file, or you can turn them on globally by editing the /etc/bash.bashrc file and uncommenting the relevant lines. You'll get magic smart tab completion for cd, apt-get, ssh, mplayer, and bajillions of other programs, and you'll wonder how you ever did without it. apt-get tab completion in particular rocks like nothing else. For example, if you type "apt-get remove x[TAB]" you'll get a complete list of installed packages starting with x. When installing, you'll get a list of available but not yet installed packages. I can't stand using apt-get without tab completion anymore.

 

pushd and popd (and other tricks) (Score:5, Informative)
by Komi (89040) <[email protected]> on Wednesday March 10, @02:41PM (#8524004)
(http://slashdot.org/)
I've read throught the tcsh man pages and stole from other people and probably the least-known most useful trick I've found is pushd and popd (which I realias to pd and po), and of course directory stack substitution. Here's a snippet of code that's really useful:
alias pd pushd
alias po popd
cd /incredi/bly/long/path/name
pd /some/other/incredi/bly/long/path/name
cp *.mp3 =1 # =1 is the first entry on the dirstack
po # returns you back to first place
The other major time saver I use are sed and awk. I used each for a specific purpose. Sed works great for substitution, and awk I use to grab columns of data. Here's a sample of how I'd use both together. This will list the home directories of the users on a machine. It's simple, but there's a ton you can do with this technique.
who | awk '{print $1}' | sort | uniq | sed 's@^@/home/@g'

Here's other stuff I have grouped by sections in my .cshrc

First, I have my shell variables. The comments say what they do. The most important one is autolist.

set autolist # automatically lists possibilities after ambiguous completion
set dunique # removes duplicate entries in the dirstack
set fignore=(\~) # files ending in ~ will be ignored by completion
set histdup=prev # do not allow consecutive duplicate history entries
set noclobber # output redirection will not overwrite an existing file
set notify # notifies when a job completes
set symlinks=ignore # treats symbolic directories like real directories
set time=5 # processes that run longer than $time seconds will be timed.

Second, bindkeys are pretty neat. I rebind the up and down arrow keys. By default they scroll up and down one at a time through the history. You can bind them to search the history based on what you've typed so far.

bindkey -k up history-search-backward # up arrow key
bindkey -k down history-search-forward # down arrow key

Third, completes allow for customizing tab completion. When I change directories, tab only completes directory names. This also works for aliases, sets, setenvs, etc.

complete cd 'p/1/d/'
complete alias 'p/1/a/'
complete setenv 'p/1/e/'
complete set 'p/1/s/'

Fourth, I have all my aliases. I had to cut a bunch because of the lameness filter.

alias cwdcmd 'ls'
alias precmd 'echo -n "\033]0;$USER@`hostname` : $PWD\007"'
alias pd 'pushd'
alias po 'popd'
alias dirs 'dirs -v'
alias path 'printf "${PATH:as/:/\n/}\n"'
alias ff 'find . -name '\''\!:1'\'' -print \!:2*'
alias aw 'awk '\''{print $'\!:1'}'\'''
alias sub 'sed "s@"\!:1"@"\!:2"@g"'
Re:pushd and popd (and other tricks) (Score:1)
by MasterLock (581630) on Wednesday March 10, @03:23PM (#8524465)
Two of my most handy aliases (tcsh and 4DOS/4NT) are:

alias mcd 'md \!*; cd \!*'

alias rcd 'setenv OLD_DIR `pwd`;cd ..;echo $OLD_DIR;rd "$OLD_DIR"; unsetenv OLD_DIR' Usage: ~/> mcd junkDir ~/junk> -- do commands, unzip files, et cetera -- ~/junk> rcd ~/> -- back where you were and the dir is gone --

Re:pushd and popd (and other tricks) (Score:1, Informative)
by Anonymous Coward on Wednesday March 10, @03:25PM (#8524497)
alias pd pushd
alias po popd
cd /incredi/bly/long/path/name
pd /some/other/incredi/bly/long/path/name
cp *.mp3 =1 # =1 is the first entry on the dirstack
po # returns you back to first place


cd /some/directory/
cd /another/directory/
cp *.mp3 ~-
cd ~-
Re:pushd and popd (and other tricks) (Score:2, Informative)
by MasterLock (581630) on Wednesday March 10, @03:33PM (#8524577)
Two of my most handy aliases (tcsh and 4DOS/4NT) are:

alias mcd 'md \!*; cd \!*'
alias rcd 'setenv OLD_DIR `pwd`;cd ..;echo $OLD_DIR;rd "$OLD_DIR"; unsetenv OLD_DIR'

Usage:
  ~/> mcd junkDir
  ~/junk> -- do commands, unzip files, et cetera --
  ~/junk> rcd
  ~/> -- back where you were and the dir is gone --

 

Top Visited
Switchboard
Latest
Past week
Past month
Quick Hacks (Score:5, Informative)
by frodo from middle ea (602941) on Wednesday March 10, @02:06PM (#8523604)
(http://aol.com/)
My 2 cent tips on budding shell script authors.

If the script is not working as you want, put a

set -x
on the fist line and
set +x
on the last line.

You will see the exact execution path and variable expansion, very neat for debugging

Re:Quick Hacks (Score:5, Informative)
by Stinky Cheese Man (548499) on Wednesday March 10, @02:15PM (#8523713)
In bash, at least, you can do this even more simply with...

sh -x scriptname

Re:Quick Hacks (Score:1)
by Tore S B (711705) on Wednesday March 10, @03:46PM (#8524725)
(http://tore.nortia.no/)
Actually, that's
bash -x scriptname

Just because sh is symlinked to bash with Linux, doesn't mean that standard /bin/sh is completely gone. Solaris puts it in /usr/gnu/bash. Same with IRIX 
Re:killing processes by name... (Score:1)
by Durin_Deathless (668544) on Wednesday March 10, @03:16PM (#8524350)
(http://tuxserver.ath.cx/~durin/)
I prefer
killall -9 [procname]
but that's just me.
Re:killing processes by name... - (Score:1)
by timbrown (578202) <[email protected]> on Wednesday March 10, @05:36PM (#8526039)
(http://www.machine.org.uk/)
Erm, Solaris has pkill and pgrep for killing and locating process by name and other process attributes.
 
Now run it. (Score:2, Informative)
by Chris Burke (6130) on Wednesday March 10, @04:01PM (#8524910)
(http://slashdot.org/)
$ uname -a
SunOS 5.8 Generic_108528-27 sun4m sparc SUNW,SPARCstation-20
$ which killall /usr/sbin/killall
Re:pushd and popd (and other tricks) (Score:2)
by cballowe (318307) on Wednesday March 10, @04:42PM (#8525394)
(http://www.steelballs.org/)
who | awk '{print $1}' | sort | uniq | sed 's@^@/home/@g'

What you really mean is

who | awk '{print $1}' | sort -u | sed 's@^@/home/@'

Which does make the assumption that user home dirs are /home/username -- not always the case. Safer is:

awk -F: '{print $6}' /etc/passwd

Remember, there's a limited number of keystrokes in a lifetime - use them wisely.
 

Re:pushd and popd (and other tricks) (Score:1)
by camh (32881) on Wednesday March 10, @06:25PM (#8526528)
alias pd pushd

alias po popd

Similar to what I have, except I use pp instead of pd (because its faster to type) and pp without args takes you to your home directory (like cd without args). To go along with it, I use
alias r "pushd +1"

alias rr "cd "$OLDPWD"

If you're working within a number of directories, use pp to get to them and then use r to rotate between the directories. rr is convenient to quickly cd somewhere else to do something and then get back again.
Re:pushd and popd (and other tricks) (Score:2)
by Ramses0 (63476) on Wednesday March 10, @07:39PM (#8527252)
My favorite "Nifty" was when I spent the time to learn about "xargs" (I pronounce it zargs), and brush up on "for" syntax.

    ls | xargs -n 1 echo "ZZZ> "

Basically indents (prefixes) everything with a "ZZZ" string. Not really useful, right? But since it invokes the echo command (or whatever command you specify) $n times (where $n is the number of lines passed to it) this saves me from having to write a lot of crappy little shell scripts sometimes.

A more serious example is:

    find -name \*.jsp | sed 's/^/http:\/\/127.0.0.1/server/g' | xargs -n 1 wget

...will find all your jsp's, map them to your localhost webserver, and invoke a wget (fetch) on them. Viola, precompiled JSP's.

Another:

    for f in `find -name \*.jsp` ; do echo "==> $f" >> out.txt ; grep "TODO" $f >> out.txt ; done ...this searches JSP's for "TODO" lines and appends them all to a file with a header showing what file they came from (yeah, I know grep can do this, but it's an example. What if grep couldn't?) ...and finally...

( echo "These were the command line params"
    echo "---------"
    for f in $@ ; do
          echo "Param: $f"
    done ) | mail -s "List" [email protected] ...the parenthesis let your build up lists of things (like interestingly formatted text) and it gets returned as a chunk, ready to be passed on to some other shell processing function.

Shell scripting has saved me a lot of time in my life, which I am grateful for. :^)

--Robert

Re:pushd and popd (and other tricks) (Score:2)
by reidbold (55120) <rmiller@uoguelp h . ca> on Wednesday March 10, @03:22PM (#8524442)
(http://beadgame.org/)
set prompt = "%{^[[032;1m%}`whoami`%{^[[0m%} %c3 %B%#%b "
I don't think anything could be more clear.

 

[Oct 15, 2003] BASH with Debugger and Improved Debug Support and Error Handling

The Bash Debugger Project contains patched sources to BASH that enable better debugging support as well as improved error reporting. In addition, this project contains the most comprehensive source-code debugger for bash that has been written.

Since this project maintains as an open CVS development and encourages developers and ideas, the space could be also be used springboard for other experiments and additions to BASH. If you are interesting in contributing to this project, please contact [email protected].

However, if you are looking for the plain vanilla BASH, try here.

BASHDB Documentation Debugger documentation online. BASH Documentation Documentation including changes to support debugging
Screenshot 1 [breakpoint] A screenshot of bashdb in Emacs Screenshot 2 [backtrace] Another screenshot of bashdb in Emacs
Download Get the latest version here. Screenshot 3 [ddd] A screenshot of bashdb under DDD
CVS Browse the CVS Tree
Sourceforge The sourceforge.net project page.

[Jun 14, 2003] The latest and greatest ksh93  Highly recommended as a replacement shell for Solaris and as an additional shell for Linux.

2003-04-22  BASE  * sol8.sun4 722124

RPMS

Index of -redhat-8.0-en-i386-at-stable-RPMS

bash-2.05b-23.i386 RPM stable version for RH 8.

bash-doc-2.05b-21.s390 RPM

[Nov 7,  2002] RE: bash 2.05b-7 and command line tab completion

I can't tell whether this bug (tab-completion adding a space when it is used for the first word after the prompt) is Cygwin-specific, or if it was added with bash 2.05. My two versions of bash running on Linux are 2.04. Neither of them have this bug. Does someone have another (non-Cygwin) bash 2.05 that can test this behavior?

> -----Original Message-----
> From: Eric Blake [mailto:[email protected]]
> Sent: Thursday, November 07, 2002 10:25 AM
> To: [email protected]
> Subject: bash 2.05b-7 and command line tab completion
> 
> 
> I'm still having problems with tab completion in the latest bash:
> 
> $ bash --version
> GNU bash, version 2.05b.0(7)-release (i686-pc-cygwin)
> Copyright (C) 2002 Free Software Foundation, Inc.
> $ ll ~/jacks/jacks # I typed ll ~/ja[TAB]jacks
> -rwxr-xr-x    1 eblake   unknown       558 Jul 24 18:33 jacks*
> $ ~/jacks jacks # I typed ~/ja[TAB]jacks
> 
> I expected to get ~/jacks/jacks both times, but the bash is 
> inserting a space after ~/directory when it is the first (but not subsequent) 
> command line word.  However, /h[TAB]e[TAB]ja[TAB]jacks now 
> works, giving /home/eblake/jacks/jacks (and it hasn't always done so in 
> prior versions of bash).  So whatever was fixed to make /-based tab completion work 
> needs to also apply to ~-based tab completion.
> 
> -- 
> This signature intentionally left boring.
> 
> Eric Blake             [email protected]
>    BYU student, free software programmer

[Mar 14, 203] Corinna Vinschen - Updated bash-2.05b-9  I've updated the version of bash in the Cygwin distro to 2.05b-9.

This version uses Cygwin's access() function now for figuring out if a user may access a file instead of it's own function to do this. This should result in more reliable results of access tests in shell scripts when running under Cygwin 1.3.21 and later. To update your installation, click on the "Install Cygwin now" link on   the http://sources.redhat.com/cygwin web page.  This downloads setup.exe to your system.  The, run setup and answer all of the questions.

[Nov 1, 2002] bash-2.05b.tar.gz is now available. NEWS

d.  `select' was changed to be more ksh-compatible, in that the menu is  reprinted each time through the loop only if REPLY is set to NULL.   The previous behavior is available as a compile-time option.

e.  `complete -d' and `complete -o dirnames' now force a slash to be appended to names which are symlinks to directories.

g.  Added support for ksh93-like [:word:] character class in pattern matching.

h.  The  $'...' quoting construct now expands \cX to Control-X.

i.  A new \D{...} prompt expansion; passes the `...' to strftime and inserts  the result into the expanded prompt.

j.  The shell now performs arithmetic in the largest integer size the  machine supports (intmax_t), instead of long.

k.  If a numeric argument is supplied to one of the bash globbing completion  functions, a `*' is appended to the word before expansion is attempted.

l.  The bash globbing completion functions now allow completions to be listed  with double tabs or if `show-all-if-ambiguous' is set.

m.  New `-o nospace' option for `complete' and `compgen' builtins; suppresses   readline's appending a space to the completed word.

n.  New `here-string' redirection operator:  <<< word.

o.  When displaying variables, function attributes and definitions are shown  separately, allowing them to be re-used as input (attempting to re-use the old output would result in syntax errors).

r.  `read' has a new `-u fd' option to read from a specified file descriptor.

u.  The `printf' %q format specifier now uses $'...' quoting to print the  argument if it contains non-printing characters.

v.  The `declare' and `typeset' builtins have a new `-t' option.  When applied to functions, it causes the DEBUG trap to be inherited by the named function.  Currently has no effect on variables.

w.  The DEBUG trap is now run *before* simple commands, ((...)) commands,   [[...]] conditional commands, and for ((...)) loops.

z.  New [n]<&word- and [n]>&word- redirections from ksh93 -- move fds (dup
    and close).

bb. The `hash' builtin has a new `-l' option to list contents in a reusable format, and a `-d' option to remove a name from the hash table.

dd. All builtins that take operands accept a `--' pseudo-option, except  `echo'.

2.  New Features in Readline

a.  Support for key `subsequences':  allows, e.g., ESC and ESC-a to both   be bound to readline functions.  Now the arrow keys may be used in vi   insert mode.

h.  Readline now has an overwrite mode, toggled by the `overwrite-mode' bindable command, which could be bound to `Insert'.

i.  New application-settable completion variable: rl_completion_suppress_append, inhibits appending of rl_completion_append_character to completed words.

j.  New key bindings when reading an incremental search string:  ^W yanks the currently-matched word out of the current line into the search string; ^Y yanks the rest of the current line into the search string,     DEL or ^H deletes characters from the search string.

-------------------------------------------------------------------------------
This is a terse description of the new features added to bash-2.05a since the release of bash-2.05.  As always, the manual page (doc/bash.1) is the place to look for complete descriptions.

g.  New `\A' prompt string escape sequence; expands to time in 24 HH:MM format.

h.  New `-A group/-g' option to complete and compgen; does group name  completion.

i.  New `-t' option to `hash' to list hash values for each filename argument.

j.  New [-+]O invocation option to set and unset `shopt' options at startup.

l.  The ksh-like `ERR' trap has been added.  The `ERR' trap will be run   whenever the shell would have exited if the -e option were enabled.   It is not inherited by shell functions.

m.  `readonly', `export', and `declare' now print variables which have been  given attributes but not set by assigning a value as just a command and a variable name (like `export foo') when listing, as the latest POSIX  drafts require.

p.  `for' loops now allow empty word lists after `in', like the latest POSIX  drafts require.

q.  The builtin `ulimit' now takes two new non-numeric arguments:  `hard',  meaning the current hard limit, and `soft', meaning the current soft  limit, in addition to `unlimited'
   
r.  `ulimit' now prints the option letter associated with a particular  resource when printing more than one limit.

s.  `ulimit' prints `hard' or `soft' when a value is not `unlimited' but is  one of RLIM_SAVED_MAX or RLIM_SAVED_CUR, respectively.

t.  The `printf' builtin now handles the %a and %A conversions if they're implemented by printf(3).

u.  The `printf' builtin now handles the %F conversion (just about like %f).

v.  The `printf' builtin now handles the %n conversion like printf(3).  The   corresponding argument is the name of a shell variable to which the  value is assigned.

2.  New Features in Readline

a.  Added extern declaration for rl_get_termcap to readline.h, making it a
    public function (it was always there, just not in readline.h).

b.  New #defines in readline.h:  RL_READLINE_VERSION, currently 0x0402,
    RL_VERSION_MAJOR, currently 4, and RL_VERSION_MINOR, currently 2.

c.  New readline variable:  rl_readline_version, mirrors RL_READLINE_VERSION.

d.  New bindable boolean readline variable:  match-hidden-files.  Controls  completion of files beginning with a `.' (on Unix).  Enabled by default.

e.  The history expansion code now allows any character to terminate a  `:first-' modifier, like csh.

f.  New bindable variable `history-preserve-point'.  If set, the history  code attempts to place the user at the same location on each history  line retrived with previous-history or next-history.

[Sept 17, 2002] BASH with Debugger and Improved Debug Support and Error Handling

The Bash Debugger Project contains patched sources to BASH that enable better debugging support as well as improved error reporting. In addition, this project contains the most comprehensive source-code debugger for bash that has been written.

Since this project maintains as an open CVS development and encourages developers and ideas, the space could be also be used springboard for other experiments and additions to BASH. If you are interesting in contributing to this project, please contact [email protected].

However, if you are looking for the plain vanilla BASH, try here.

Documentation On-line documentation.
Download Get the latest version here.
CVS Browse the CVS Tree
Sourceforge The sourceforge.net project page.

[Jul 18, 2002] The GNU Bourne-Again Shell bash 2.05 is now available; most important NEWS:

GNU shtool 1.6.1 Ralf S. Engelschall Saturday, July 13th 2002 15:28 EDT

About: GNU shtool is a compilation of small but very stable and portable shell scripts into a single shell tool. All ingredients were in successful use over many years in various free software projects. The compiled shtool program is intended to be used inside the source tree of free software packages. There it can overtake various (usually non-portable) tasks related to the building and installation of an free software package.

Changes: The non-existent --min-size option was removed from the usage of "shtool rotate". The following was ported to the POSIX 1003.1-2001 (SUSv3) standard: sh.echo, sh.version, sh.path, sh.subst. Various typos in shtool.pod were fixed.

Version Focus Date
1.6.1 Minor bugfixes 13-Jul-2002 15:28

5 Bash tips every Linux user should know - Aug 22, 2001

  1. Finding your history the easy way When using the up arrow key, there is the problem of, "When was the last time I typed that command?" If you know that you have typed the command in the last few days but you don't want to use the up arrow 400 times to find it, there are two simple ways to find your command. The first is with the  history and grep commands. The next time you find yourself in such a situation, type:

    history|grep -i first few letters of command

    This will read the history file (located in ~/.history) and perform a case insensitive search on the command you are looking for. Here is example output from my machine:

         [jd@jd bash]$ history|grep -i POSTGRES
         29  cvs update -d postgres
         30  cd postgres/
         61  cd projects/postgres/ 

    I now have a list of commands that match my requirements. If the command is in the list, I can use the ! key to execute one of the commands. If I wanted to execute dvips -f practicalpostgresql.dvi -o practicalpostgresql.ps, for example, I could just type !73 which is the corresponding history number with the command I want to execute. The second method of finding the command you are looking for is to use history completion, which is discussed next.
     

  2. History completion.The next time you need a previously entered command, type ctrl-r and then begin typing the command. You will notice ctrl-r finishes the command for you as you type. If you can remember to use ctrl-r, it will become invaluable for repeating longer commands.
  3. Tab completion. Tab completion is similar to history completion, except that tab completion won't complete a previously run command. Instead, the tab completion will finish the name of a command or file that exists within a directory. If I am at a command prompt and I type cd /usr/local/ but I don't quite remember the name of the next directory in the path I can use the tab key to have Bash auto-complete the name. If there are multiple directories or file available, Bash will beep to indicate that there is not a clear option to complete. It will then display a listing of the available options if you press tab again. Here is example output when using tab completion to enter a directory in

    [jd@jd bash]$ cd /usr/local/
    HancomOffice    Loki_Update     bin             etc             info
    man             prod            soffice
    Loki_Uninstall  appgen          doc             games           lib
    mozilla         sbin            src

  4. Aliasing Is there a command that has several parameters that you use a lot? Here at Command Prompt, we are using Jade to process DocBook XML and SGML. Jade will require numerous parameters on execution. As an example, here is the Jade syntax to process an SGML file, and transform it into HTML.
    
      

    jade -E 200 -t sgml -V html-index -d /usr/lib/sgml/stylesheets/nwalsh-modular/html/docbook.dsl practicalpostgresql.sgml

    This would be difficult and tiresome to type over and over as you are writing and processing a document. Instead, you can use the alias bash command. Using the above example we can use the alias command like this:

    alias pghtml='jade -E 200 -t sgml -V html-index -d /usr/lib/sgml/stylesheets/nwalsh-modular/html/docbook.dsl practicalpostgresql.sgml'

    Now, if you type just pghtml at the command line, it will process the aliased jade command. Place this in your .bash_profile, or else it will not be stored in memory the next time you log in. You can have any amount of aliases that you desire, though they must, of course, have unique names. On my system the output looks like this:

    [jd@jd practicalpostgresql]$ alias
    alias l='ls'
    alias la='ls -A -k'
    alias ll='ls -l'
    alias ls='ls -F --color=auto'
    alias lsd='ls -d */'
    alias md='mkdir'
    alias p='cd -'

[May 17, 2002] Since v2.04, bash has allowed to intelligently program and extend its standard completion behavior to achieve complex command lines with just a few keystrokes.

Imagine typing ssh [Tab] and being able to complete on hosts from your ~/.ssh/known_hosts files. Or typing man 3 str [Tab] and getting a list of all string handling functions in the UNIX manual. mount system: [Tab] would complete on all exported file-systems from the host called system, while make [Tab] would complete on all targets in Makefile.

[Mar 25, 2002] UnixReview.com/Shell corner  -- some potentially useful scripts.

[Mar 10, 2002] Unix pipes -- examples of scripts that use pipes. Most examples are pretty trivial.

GNU shtool - GNU Project - Free Software Foundation (FSF) Several useful scripts (bash):

Useless Use of Cat Award

In a recent thread on comp.unix.shell, the following example was posted by Andreas Schwab as another Useful Use of Cat on a lone file:

	{ foo; bar; cat mumble; baz } | whatever

Here, the contents of the file mumble are output to stdout after the output from the programs foo and bar, and before the output of baz. All the generated output is piped to the program whatever. (Read up on shell programming constructs if this was news to you :-)

Advanced Bash-Scripting Guide Revision 1.1, 06 January 2002 Daniel Robbins' three-part series on bash programming on developerWorks: Part 1, Part 2, and Part 3.

ksh93 rpms:

**** Example of ksh profile  that contains interesting but probably non-optimal way to distinguish between interactive and non-intractive shells [Feb 2, 2002]

ENV='$\{FILE[(\_\$-=0)+(\_=1)-\_\$\{-\%\%*i*\}]\}'
export ENV

Advanced Bash-Scripting Guide -- by Mendel Cooper [06 Jan, 2002[

Revision 1.1 06 January 2002 Revised by: mc
Bugfixes, material and scripts added.

This tutorial assumes no previous knowledge of scripting or programming, but progresses rapidly toward an intermediate/advanced level of instruction (...all the while sneaking in little snippets of UNIX wisdom and lore). It serves as a textbook, a manual for self-study, and a reference and source of knowledge on shell scripting techniques. The exercises and heavily-commented examples invite active reader participation, under the premise that the only way to really learn scripting is to write scripts.

The latest update of this document, as an archived "tarball" including both the SGML source and rendered HTML, may be downloaded from the author's home site. See the change log for a revision history.

developerWorks Linux Using Bash shell scripts for function testing

"Function testing is the phase during a development cycle in which the software application is tested to ensure that the functionality is working as desired and that any errors in the code are properly handled. It is usually done after the unit testing of individual modules, and before a more thorough system test of the entire product under load/stress conditions."

"There are many testing tools in the marketplace that offer a lot of functionality to help with the testing efforts. However, they need to be obtained, installed, and configured, which could take up valuable time and effort. Bash can help to speed things along."

Functions and aliases in bash" also http://www.linuxgazette.com/issue53/eyler.html 

Variable Mangling in Bash with String Operators LG #57 by Pat Eyler (see also Variable Mangling in Bash with String Operators

Have you ever wanted to change the names of many files at once? How about using a default value for a variable if it has no value? These and many other options are available to you through string operators in bash and other bourne shell derived shells. 

String operators allow you to manipulate the contents of a variable without having to write your own shell functions to do so. They are provided through 'curly brace' syntax. Any variable can be displayed like this ${foo} without changing its meaning. This functionality is often used to protect a variable name from surrounding characters.

bash-2.02$ export foo=foo
bash-2.02$ echo ${foo}bar # foo exists so this works
foobar
bash-2.02$ echo $foobar # foobar doesn't exist, so this fails

bash-2.02$ 

By the end of this article, you'll be able to use it for a whole lot more. 

There are three kinds of variable substitution:

I'll talk about the first two and leave command substitution for another article. ... If you're interested in more hints about bash (or other stuff I've written about), please take a look at my home page.

Column - Ed Schaefer - The Shell Corner -- Each month UnixReview.com will publish a selected script in this column. I will evaluate the submissions and award each winner $100.00 courtesy...

Welcome to the inaugural edition of the Shell Corner column. The premise of Shell Corner is simple: You, the Unix professional send in your favorite Unix shell script and each month UnixReview.com will publish a selected script in this column. I will evaluate the submissions and award each winner $100.00 courtesy of UnixReview.com. What could be more simple?

Joe Casad, UnixReview.com senior editor, wanted a "shell guru" to author this column, but ended up with me instead. My experience is mostly as a Unix business applications programmer and not as a systems administrator. I feel my attitude is more minimalist than most, and my script evaulations are certain to reflect this. I enjoy scripts that are (relatively) easy to read and well documented. If I have trouble reading a script, chances are I'll quickly go to the next one.

What are the limitations on script submissions? I can think of no limitation, other than length. Use any of the Unix tools such as Perl, awk, sed, etc, as well as high level languages, such as C or C++. I'll even struggle through assembler if you will.... ... ...

# tolower.sh: convert file names to lower case
# in the current working directory
# Choose either all the files in a directory or a command-line list
if [ "$#" -gt 0 ]; then
   filelist="$@" # just the files on command line
else
   filelist=`ls` # all files
fi
for file in $filelist; do
# Use the grep command to determine if the file has an upper case letter
# Determine the destination of the mv command by down shifting all the 
# letters in the file name. Command substituting an echo of the 
# file name to the translate filter, tr, performs the downshift
   if echo "$file"|grep [A-Z] > /dev/null; then
      mv "$file" `echo "$file"|tr "[A-Z]" "[a-z]"`
   fi
done   

Bourne Shell Programming by Robert P. Sayle

Some useful links from About.com:

Mailing From Scripts(Jul 29, 2000) About.com: Calling Commands When Booting [init script](Jul 29, 2000) Linux Gazette: The Deep, Dark Secrets of Bash(Jul 08, 2000) Linuxnewbie.org: Bash Programming Cheat Sheet(Jun 14, 2000) IBM developerWorks: Bash by example, Part 2(Apr 09, 2000) Linux Gazette: Introduction to Shell Scripting--The Basics(Apr 02, 2000) shellscript.org: Share UNIX/Linux scripts/applets(Apr 00, 2000) IBM developerWorks: Bash by example, Part 1(Mar 30, 2000) Ext2: Shell Scripting Part One(Feb 27, 2000)

*** Of Unix shells and environment variables -- Mo Budlong small tutorial.(2,200 words)


Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 13, 2004