USA Linux Users Group Forum Index
Log in Register FAQ Memberlist Search USA Linux Users Group Forum Index Album

Learning the bash Shell / By Cameron Newham, Bill Rosenblatt
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Reviews and Interviews
View previous topic :: View next topic  
Author Message
crouse
Site Admin


Joined: 17 Apr 2024
Posts: 11833
Location: Iowa

PostPosted: Thu Jan 29, 2024 9:58 pm    Post subject: Learning the bash Shell / By Cameron Newham, Bill Rosenblatt Reply with quote



Reviewer: Germ

The Book:
Learning the bash Shell
By Cameron Newham, Bill Rosenblatt
334 pages
2nd Edition January 1998
ISBN: 1-56592-347-2

Book Link: http://www.oreilly.com/catalog/bash2/
Code Examples: http://examples.oreilly.com/bash2/


If you are a user of Linux/Unix, sooner or later you will need to use the shell. The Free Software Foundation's "Bourne Again Shell" is the most widely used. Learning the bash Shell Second Edition by Cameron Newman and Bill Rosenblatt is nearly indispensible in order to gain a fantastic working knowledge of the bash shell. The book is geared towards bash 2.0, but is also relevant to bash 1.x.

This book is written for beginners and takes you from the basics all the way to system administration. Even the old pros are likely to learn a trick or two. It covers features of bash all the way to the "wow, I didn't know bash could do that!" level. People have come to expect well written, easy to read, and professional books from O'Reilly and this title is no exception.

Chapter 1 starts with the basics. You will gain knowledge of the directory and file structure, how to install bash as your login shell, and the basics of interactive shell use. The successive chapters will take you all the way to system administration. Each chapter of the book builds on what you have learned in Previous chapters.

Chapter 2 teaches you about command line editing. You can put bash in edit mode and edit command lines just as you would edit text with a text editor.

Chapter 3 tells you how to customize your environment. One of the more useful things to me are aliases. Do you use a lengthy command quite often? Create an alias for that command and give your fingers a rest. The authors tell you how.

Chapter 4 covers basic shell programming. You'll learn how to write and edit shell scripts.

The book continues with coverage of Flow Control, Command Line Options, Input/Output Processing, Process Handling, Debugging, Getting and Installing bash, and Administration. It finishes with some extremely useful appendices covering Related Shells, Reference Lists, Loadable Built-Ins, Systax, and Obtaining Sample Programs.

I am no guru, but I know my way around the CLI and one thing I found especially useful for me is Appendix B. It contains lists of options, built-in commands and variables, and I/O redirections among other commands.

The authors have provided tons of examples from commands to scripts and the major scripts are available for download from O'Reilly at the link above.

If you just want to be confortable using the command line interface or want to go all the way to a working knowledge of writing your own scripts and administering your system or a network, this is the book for you.

Many thanks to O'Reilly and Associates for providing this book to USAlug for review.
It's a must have for anyone using Linux/UNIX.
I give Learning the bash Shell 5/5 Big Grins. Very Happy Very Happy Very Happy Very Happy Very Happy


Back to top
View user's profile Send private message Visit poster's website AIM Address
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Thu May 06, 2024 6:12 pm    Post subject: Good resource! Reply with quote

I have both books, Learning the Bash Shell and Learning the Korn Shell. There is quite a bit of overlap between the two books. In fact if you have one of them, there's really no essential need to get the other one. The Korn Shell and the Bash Shell, though certainly distinct, with their own set of features, do have the bulk of their features in common. There is a section in each book that describes the differences between the Bash or Korn shells and other shells that use the Bourne Shell syntax.

There is another family of shells that use the C Shell syntax (csh and tcsh). There is also a shell, zsh, that has features and syntax from both shells. Zsh is a Bourne Shell based shell, but it is really quite a hybrid shell and is the mother of all interpretive, interactive shells.

I found both of these books to be quite useful. I should also note that these books are a bit dated and haven't kept up with recent feature additions, but they still serve as a very useful resource to learn how to use shell scripts effectively.


Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
maillion
Advanced Member


Joined: 30 Mar 2024
Posts: 791
Location: Texas, USA, Terra

PostPosted: Thu May 06, 2024 7:47 pm    Post subject: Reply with quote

I will most likely buy it, because I need something a little more detailed than what is in my outdated Linux book. Nice review, crouse! Cool


Back to top
View user's profile Send private message
crouse
Site Admin


Joined: 17 Apr 2024
Posts: 11833
Location: Iowa

PostPosted: Thu May 06, 2024 7:50 pm    Post subject: Reply with quote

Thanks.... but I just post em.... that was reviewed by GERM !! Wink


Back to top
View user's profile Send private message Visit poster's website AIM Address
maillion
Advanced Member


Joined: 30 Mar 2024
Posts: 791
Location: Texas, USA, Terra

PostPosted: Thu May 06, 2024 8:06 pm    Post subject: Reply with quote

crouse wrote:
Thanks.... but I just post em.... that was reviewed by GERM !! Wink


Well, then, thanks to you, germ! (and my thanks to you is still applicable, crouse!) Sorry, I just scanned the review - I didn't see the author's name... Embarassed


Back to top
View user's profile Send private message
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Fri May 07, 2024 1:46 am    Post subject: Reply with quote

maillion wrote:
I will most likely buy it, because I need something a little more detailed than what is in my outdated Linux book. Nice review, crouse! Cool


If it's the shell you want more details on, this is definitely the book to get. Though in need of an update to include the very latest changes, the core of the book is very useful and accurate, and will serve you well, even if the shell continues to occasionally get a few new features. The main stuff is, and has been, the same for many years now.


Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
maillion
Advanced Member


Joined: 30 Mar 2024
Posts: 791
Location: Texas, USA, Terra

PostPosted: Fri May 07, 2024 1:54 am    Post subject: Reply with quote

masinick wrote:
maillion wrote:
I will most likely buy it, because I need something a little more detailed than what is in my outdated Linux book. Nice review, crouse! Cool


If it's the shell you want more details on, this is definitely the book to get. Though in need of an update to include the very latest changes, the core of the book is very useful and accurate, and will serve you well, even if the shell continues to occasionally get a few new features. The main stuff is, and has been, the same for many years now.


Shell scripting, actually, but to learn that I need to learn the shell... Surprised


Back to top
View user's profile Send private message
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Fri May 07, 2024 2:00 am    Post subject: Learn to use the shell interactively, that will help Reply with quote

maillion wrote:
masinick wrote:
maillion wrote:
I will most likely buy it, because I need something a little more detailed than what is in my outdated Linux book. Nice review, crouse! Cool


If it's the shell you want more details on, this is definitely the book to get. Though in need of an update to include the very latest changes, the core of the book is very useful and accurate, and will serve you well, even if the shell continues to occasionally get a few new features. The main stuff is, and has been, the same for many years now.


Shell scripting, actually, but to learn that I need to learn the shell... Surprised


You can certainly learn a lot about shell scripting with this book and see lots of useful examples. I probably have at least a few of them in my own .bashrc, .profile, or both.


Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
maillion
Advanced Member


Joined: 30 Mar 2024
Posts: 791
Location: Texas, USA, Terra

PostPosted: Fri May 07, 2024 2:11 am    Post subject: Reply with quote

masinick wrote:
You can certainly learn a lot about shell scripting with this book and see lots of useful examples. I probably have at least a few of them in my own .bashrc, .profile, or both.


I definitely learn best from examples, and if the examples are useful in everyday life, that is extra icing on the cake... Smile


Back to top
View user's profile Send private message
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Fri May 07, 2024 7:46 pm    Post subject: Reply with quote

Some of the stuff in here was originally written for use with the Korn Shell (ksh) rather than Bash, but the majority of it will work with most Bourne based shells, including sh, sh5, ksh, ash, zsh, and of course, bash. There are a few isolated things that don't really work properly if you have a version 1.* bash implementation, but if you're running Bash 2.0.4 or newer, virtually all of it should work.

Some of the junk won't be directly applicable to you, but you can get a good idea of how shell scripts work. I hope you find this example useful!
====================

# File: .profile
#
# Author:
# Brian W. Masinick
# Purpose:
#
# Establishes a regular login environment, containing environment
# variables which affect the text editors used, the ODE (sandbox
# development environment), access to custom software and tools, and
# regular productivity aids. This procedure relies on shell
# functionality found in the Korn Shell (ksh) and would probably
# also work with the GNU Bourne-again shell (bash), but that has not
# been tested, nor has this been tested against the standard Bourne
# Shell. It is guaranteed not to work on any shell that does not
# support functions and procedures, which are heavily used
# throughout.

TheYiExports() # set and export environment variables
{
HOST=`hostname`
# Strip off domain name; e.g., change flume.zk3.dec.com to flume.
HOST=`expr "$HOST" : '\([^\.]*\)'`
export HOST

# set up to use CD player. The application xcd runs the player.
# /dev/cam must be set to mode 644 and /dev/rrz4c must be set to mode 666.

CDROM=/dev/rrz4c; export CDROM
XMCD_LIBDIR=~/lib/X11/xmcd/; export XMCD_LIBDIR

# export the local Web related environment. I'm not 100% certain
# that I need to do this in .profile, as I also do it in .kshrc.
# But there are a small number of variables, and it certainly
# doesn't hurt anything.

ftp_proxy=http://www-proxy.zko.dec.com:8080/; export ftp_proxy
http_proxy=http://www-proxy.zko.dec.com:8080/; export http_proxy
no_proxy=.dec.com; export no_proxy

COLUMNS=132; export COLUMNS # defines a 132 column logical shell display
ENV=$HOME/.kshrc; export ENV # specifies a custom environment, in this
# case, my Korn Shell .kshrc file.

FCEDIT=emacs; export FCEDIT # defines the editor used with ksh to do
# command line editing. This is redundant
# when I also have set -o emacs defined. (so what)

FPATH=$HOME/lib; export FPATH # personal software library
MAIL=/usr/spool/mail/$USER # location of incoming mail.
export MAIL
MAILDROP=/usr/spool/mail/$USER # location of incoming mail.
export MAILDROP
LOGNAME=$USER; export LOGNAME # user login name
NAME="Yi Wang"; export NAME
NNTPSERVER=nntpd.bb.dec.com
export NNTPSERVER # Local Usenet server
PRINCIPAL=Yi_Wang
export PRINCIPAL # ODE Principal Name
# PRINTER=doc2
PRINTER=i18n
export PRINTER # Default local printer
SIGNATURE="Yi Wang"; export SIGNATURE

}

TheYiOS() # figure out which OS we're on to do specific stuff
{
case "$OS" in
"ULTRIX")
PATH=/etc:/usr/ucb:/bin:/usr/bin:/usr/bin/X11:/usr/bin/mh
PATH=$PATH:$HOME/bin:$HOME/tools/bin
PATH=$PATH:/usr/local/bin:/tools/bin:.:
export PATH
EDITOR=vi; export EDITOR
VISUAL=/usr/bin/emacs; export VISUAL
;;
"OSF1")
CPU=`/usr/sbin/sizer -c | awk -F\" '{print $2}'`; export CPU
PATH=/usr/dt/bin
PATH=$PATH:/usr/bin/X11
PATH=$PATH:/usr/bin
PATH=$PATH:/bin
PATH=$PATH:/sbin
PATH=$PATH:/usr/sbin
PATH=$PATH:/usr/projects/sa/i18neng/tools/bin
PATH=$PATH:$HOME/bin:$HOME/tools/bin
PATH=$PATH:/usr/bin/mh:/etc
PATH=$PATH:$SDETOOLSBIN
PATH=$PATH:/usr/local/bin:/tools/bin:.:
export PATH
EDITOR=emacs; export EDITOR
VISUAL=emacs; export VISUAL
;;
esac

}

TheYiPath() # Establish default paths depending on system type
{

SDETOOLSBIN=/usr/sde/tools/${MACHINE}_${OS}/bin; export SDETOOLSBIN
if [ "$SHELL" = "ksh" ]
then
unset PATH
fi

TheYiOS

MANPATH=/usr/man:/usr/local/man:/usr/dt/man:~/man; export MANPATH
#MANPATH=/usr/i18n/share/ja_JP/man # Use when testing Japanese fonts.

case "$SESSIONTYPE" in
"dx")
XUSERFILESEARCHPATH=$HOME/%N; export XUSERFILESEARCHPATH
;;
*)
UIDPATH=/usr/lib/X11/uid/%U%S:/usr/local/lib/X11/uid/%U%S:./%U%S;
export UIDPATH
XAPPLRESDIR=$HOME/app-defaults; export XAPPLRESDIR
XUSERFILESEARCHPATH=/usr/local/lib/X11/app-defaults/%L/%N
XUSERFILESEARCHPATH=$XUSERFILESEARCHPATH:$HOME/app-defaults/%N
export XUSERFILESEARCHPATH
;;
esac

}

######################################################################
#
# Main
#
# The logic below drives the flow of the entire procedure.
#
######################################################################

MACHINE=`machine`; export MACHINE
OS=`uname`; export OS
TheYiPath
TheYiExports


# Set the directory and file protection mask so that, by default, I do
# not mask owner file protections, but I mask out write access to group,
# and all access to world. This, of course, can be overridden by using
# chmod and chown to change the mode (file protection) and owner,
# respectively, of directories and files.

umask=022

# The following condition checks to see if we are operating in a CDE
# "DT", that is, a CDE Desktop environment. If we are, then we do not
# want to set terminal characteristics. But if we are running a
# terminal emulator, such as dtterm, dxterm, or xterm, then we DO want
# to perform the following steps:

if [ ! "$DT" ]; then
PS1="$HOST> "
tty -s
if test $? = 0
then
stty dec crt
fi
tset -Q -I
fi

case "$OS" in
"ULTRIX")
HISTFILE=~/.bwm_ksh_history; export HISTFILE
;;
*)
HISTFILE=/tmp/.bwm_ksh_history; export HISTFILE
;;

esac

# HISTFILE is where history is saved. As an
# alternative, /tmp/.hist$$ would create a unique history file for
# each shell I login to, but then I have to purge these files.
# Not a big deal, but I prefer it this way.

HISTSIZE=1500; export HISTSIZE # Max. size of the history file

# Turn off "informative messages"
biff n

# Finished .profile
# +++ Added by i18nsetup +++
[ -f /etc/i18n_profile -a -d /usr/bin ] && . /etc/i18n_profile
# --- i18nsetup End ---



_________________
Brian Masinick
Distros: SimplyMEPIS
sidux - no CAPS!, antiX, Debian
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Fri May 07, 2024 7:55 pm    Post subject: Reply with quote

By the way, I wrote that procedure for myself originally many years ago when I was at Digital Equipment Corporation (which became Compaq, which became Hewlett Packard). I created a fairly generic procedure that many people could use with only minor changes. We'd change the names where names exist, and we'd change the procedures, where procedures exist. I originally wrote the procedure with the procedure name prefix "TheMas", then when I gave it to other people, we'd change the name - like "TheYi" or "TheZig". When I left Digital, I ran out of time to copy some of my favorite procedures off to a Yahoo repository, so I had my friends, Yi Wang and Ziggy Korona send me copies of stuff I wrote for them. The previous example is the one Yi sent back to me, so it's actually my work, which in turn, is a collection of stuff from Rosenblatt's book, Ken Miller, Tom Woodburn, and a few other people at Digital, plus a smattering of ideas found in newsgroups and other nooks and crannies. My creation is thus the collection of ideas from many people and my own innovations. I'll take the heat for any errors, poor practices, or anything else that's lacking in it. Smile



_________________
Brian Masinick
Distros: SimplyMEPIS
sidux - no CAPS!, antiX, Debian
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Fri May 07, 2024 8:28 pm    Post subject: Reply with quote

#
# File: .bashrc
#
# Author:
# Brian W. Masinick
# Purpose:
# Defines variables, aliases, and functions for shortening typing
# and tasks. Used with the Bourne Again Shell, bash, from the GNU
# project of the Free Software Foundation.
#
# NOTE: This file is an adaptation of my .kshrc file, removing things
# that are peculiar to the Korn Shell, ksh.
#
# Conventions:
# I define every procedure and function using UpperCase Words Like
# this and prepend each name with TheYi to reduce the likelihood of
# a naming collision with a command, script, or program.

# The procedures are invoked at the bottom of the file. The
# functions or procedures can be called at any time by any
# procedure, which is why breaking the procedures and functions into
# similar groupings makes sense. The organization of the procedures
# may need to be adjusted periodically to keep in step with my
# current work.

# exit if not interactive

case "$-" in
*i*) ;;
*) return ;;
esac

TheYiPoolTools() # define pool and tool directory variables
{

#
# define some aliases used with sandboxes and/or ODE
#

alias kd="kdestroy"
alias ki="kinit $PRINCIPAL"
alias kl="klist"
alias mm='make clean;make includes;make depend;make'
alias pool="cd /usr/sde/osf1/build/steelcde.nightly/src/cde1/localized"

bst=~brians/tools/bin
bmt=~masinick/tools/bin
bsw=~brians/work/bin
twt=~woodburn/cde/tools/bin
cdenext=/cdenext/proj/cde/programs/localized
proj=/usr/projects/sa/i18neng/tools/bin
stcde=/usr/sde/osf1/build/steelcde/src
stcde1=/usr/sde/osf1/build/steelcde.nightly/src
}

TheYiWebExports() # define the environment variables to be exported.
{

# export the CDROM location so that it can be used from a
# window manager. Whenever an upgrade is performed, be sure to
# do a chmod 644 /dev/cam and chmod 666 /dev/rrz4c.

export CDROM=/dev/rrz4c

#
# export a bunch of stuff for xmosaic and lynx.
#

export ftp_proxy=http://www-proxy.zko.dec.com:8080/
export http_proxy=http://www-proxy.zko.dec.com:8080/
export no_proxy=.dec.com

}

TheYiPrinters() # define printer aliases
{

#
# Printing aliases...
#

alias lpi='lpr -P i18n -K2 -N1'
alias lpd='lpr -P doc2 -K2 -N1'
alias lp1='lpr -P doc1 -K2 -N1'
alias lp2='lpr -P doc1 -K2 -N2'
alias lp_doc1='lpr -P doc1 -K2 -N1'
alias lpq_doc1='lpq -P doc1'
alias lpq_doc2='lpq -P doc2'
alias lp_l='lpr -P doc1 -O landscape'
alias lp_l_i18n='lpr -P i18n -O landscape'
alias lp_i18n='lpr -P i18n -K2 -N1'
alias lp2_i18n='lpr -P i18n -K2 -N2'
alias lpq_i18n='lpq -P i18n'
alias lp_calvin='lpr -P calvin -K2 -N1'
alias lp2_calvin='lpr -P calvin -K2 -N2'
alias lpq_calvin='lpq -P calvin'
alias lp_archie='lpr -P archie -K2 -N1'
alias lp2_archie='lpr -P archie -K2 -N2'
alias lpq_archie='lpq -P archie'
alias lp_halmrk='lpr -P halmrk -K2 -N1'
alias lp2_halmrk='lpr -P halmrk -K2 -N2'
alias lpq_halmrk='lpq -P halmrk'
alias lp_hobbes='lpr -P hobbes -K2 -N1'
alias lp2_hobbes='lpr -P hobbes -K2 -N2'
alias lpq_hobbes='lpq -P hobbes'
alias lp_shubox='lpr -P shubox -K2 -N1'
alias lp2_shubox='lpr -P shubox -K2 -N2'
alias lpq_shubox='lpq -P shubox'
alias ml='rm -fre /tmp/.yi-lprstatus; for i in doc1 i18n ;do echo Printer:
$i >>/tmp/.yi-lprstatus; lpq -P$i >>/tmp/.yi-lprstatus; done;more
/tmp/.yi-lprstatus; rm -fre /tmp/.yi-lprstatus'

}

TheYiMisc() # miscelaneous aliases I like to use
{
alias bye='clear; kill -1 0'
alias c="clear;pwd"
alias cls=clear sd=cd
alias lo='clear; kill -1 0'
alias m='more'

# changing keypad mappings...
KEYDIR=/usr/examples
alias lkkeys='$KEYDIR/pc_to_lk_keys.sh'
alias pckeys='$KEYDIR/pc_to_lk_keys.sh -u'

# miscelaneous miscelany...

alias help=apropos
alias wn='who -uT | fgrep .'

# history aliases...

alias h='fc -l'
alias re='fc -e -'
alias zaphist="rm -f /tmp/.yi_history"

# host aliases...

alias host=hostname
alias rw="rwho | sort +1"

# desktop office tool aliases...

alias bh='exec ~/bin/bash'
alias e=emacs
alias kh='exec /usr/bin/ksh'
alias n=next
alias p=prev
alias R='repl -cc all -filter ~/.mhfilter'
alias um=UnseenMail

}

TheYiFileManagement() # commands I use to operate on files and dirs.
{
# directory movement aliases...

alias b="cd ~/bin"
alias cd='g'
alias home=cd

# file management aliases...

alias del="rm -i"
alias copy=cp
alias del='rm -i'
alias dir="ls -aqFC"
alias type=cat
alias l='ls -aqCF'
alias lsd='ls -algFqd'
alias lsf='ls -F'
alias lsi='ls -algFqi'
alias lsl="ls -algFq"
alias lsr='ls -aqCFR'
alias lst="ls -algsFqt"
alias lst10="lst | head -10"
alias lst20="lst | head -20"
alias lst30="lst | head -30"
alias lst40="lst | head -40"
alias lst50="lst | head -50"
alias lst60="lst | head -60"
alias lst70="lst | head -70"
alias pdw=pwd
alias pd=pwd
alias wpd=pwd
}

TheYiTerm()
{

alias vt52="TERM=vt52; export TERM"
alias vt100="TERM=vt100; export TERM"
alias vt102="TERM=vt102; export TERM"
alias vt200="TERM=vt200; export TERM"
alias vt300="TERM=vt300; export TERM"
alias vt400="TERM=vt400; export TERM"
alias xrs='set noglob; eval `resize -s \!\*`; unset noglob'
alias xs='set noglob; eval `resize`; unset noglob'
}

TheYiWorkon()
{

####################################################################
#
# Tom Woodburn's stuff (adapted) below...
#
####################################################################

export HISTFILE=/tmp/.yi_bash_history
export HISTSIZE=1500

HOST=`hostname`
# Strip off domain name; e.g., change flume.zk3.dec.com to flume.
HOST=`expr "$HOST" : '\([^\.]*\)'`
export HOST

case "$WORKON" in
"")
PS1="$HOST:`whoami`> "
;;
*)
PATH=$SDETOOLSBIN:$PATH:
PATH=$PATH:$HOME/bin:
PATH=$PATH:$HOME/tools/bin:
PATH=$PATH:/usr/projects/sa/i18neng/tools/bin
PATH=$PATH:/usr/dt/bin:
PATH=$PATH:/usr/bin/X11:
PATH=$PATH:/usr/bin/mh:
PATH=$PATH:/usr/local/bin:
PATH=$PATH:/contrib/bin:
PATH=$PATH:/usr/java/bin:
export PATH
CLASSPATH=/usr/java/classes
export CLASSPATH
case "$SANDBOX" in
"")
SANDBOX=`dirname $SOURCEBASE`
SANDBOX=`basename $SANDBOX`
;;
esac
export SBTOPDIR=$HOME/$SANDBOX/src
case "$BCSSET" in
"")
SET=$SANDBOX
;;
*)
SET=`expr "$BCSSET" : "${PRINCIPAL}_\(.*\)"`
;;
esac
PS1="[$HOST:(`whoami`) $SANDBOX($SET)] "
# if DISPLAY exists, set titlebar and icon.
if [ -n "$DISPLAY" ]; then
~/bin/title "Sandbox set $PS1 for $USER" $HOST
fi
unset LANG
;;
esac
}

TheYiHosts() # define host aliases...
{

# rl is a procedure in my bin directory that alters the title bar,
# then calls rlogin.

alias abyss='rl abyss'
alias aeiou='rl aeiou'
alias aijin='aijin'
alias alpha='rl alpha'
alias america='rl america'
alias aosg='rl aosg'
alias asia='rl asia'
alias baggy='rl baggy'
alias burnit='rl burnit'
alias brilor='rl brilor'
alias ditch='rl ditch'
alias europe='rl europe'
alias flume='rl flume'
alias fonz='rl fonz'
alias ftphost='Telnet ftphost'
alias gobblr='rl gobblr'
alias gorge='rl gorge'
alias gulp='rl gulp'
alias hawkeye='rl hawkeye'
alias herron='rl herron'
alias hunch='rl hunch'
alias istanbul='rl istanbul'
alias krisis='rl krisis'
alias mickey='rl mickey'
alias osfris='rl osfris'
alias oskits='rl oskits'
alias paris='rl paris'
alias quarry='rl quarry'
alias r2me2='rl r2me2'
alias sapphire='rl sapphire'
alias shauni='rl shauni'
alias smurf='rl smurf'
alias soak2='rl soak2'
alias taxus='rl taxus'
alias themas='rl themas'
alias tlaser='rl tlaser'
alias unixris='rl unixris'
alias wasted='rl wasted'
alias xappl='rl xappl'
}


#########################################################################
#
# Bill Gray's functions (adapted) below...
#
#########################################################################

# directory stack functions

declare -i DNUM=0
DLIST[DNUM]=`pwd`

function g # go to a directory
{
if builtin cd "$@" >/dev/null && [ ${DLIST[DNUM]} != "$PWD" ]
then
DNUM=DNUM+1
DLIST[DNUM]=$PWD
fi
case $WORKON in
"")
# if DISPLAY exists, then set titlebar and icon.
if [ -n "$DISPLAY" ]; then
titlebar="$USER @ $HOST : $PWD"
if [ "$OS" = "OSF1" ]; then
~/bin/title "$titlebar" "$HOST"
else
~/bin/utitle "$titlebar" "$HOST"
fi
fi
;;
*)
;;
esac
pwd
}

function gb # go back
{
if (( $DNUM > 0 ))
then
DNUM=DNUM-1
fi
g ${DLIST[DNUM]}
}

function gn # go to selected (nth) dir
{
select DIR in `echo ${DLIST[*]} | tr " " "\012" | sort -u -y0`
do
if [ "$DIR" ]
then
g $DIR
else
g $REPLY
fi
break
done
}

function up # go up n levels
{
declare -i levels

levels=${1}

if [ -z "${1}" ] && [ ${PWD} != "/" ]
then
g ..
return $?
fi

while [ ${levels} -gt 0 ] && [ ${PWD} != "/" ]
do
g ..
levels=levels-1
done
}


function lpit
{
for file in $*
do
pr -e8 -f $file | lpr -J $file -P doc1
done
}

function lpsrc
{
for file in $*
do
pr -e8 -f -n5 $file | lpr -J $file -P doc1
done
}

function lp_2sides
{
for file in $*
do
pr -e8 -f -n5 $file | lpr -J $file -P doc1 -K 2
done
}

function lp_2sides_2up
{
for file in $*
do
pr -e8 -f -n5 $file | lpr -J $file -P doc1 -K 2 -N 2
done
}

function t
{
export TERM=$1
xs
}

function addpath
{
PATH=$PATH:$1
echo $PATH
}

function log
{
echo `date '+%D %H:%M'` >> ~/.logfile
echo "$*" >> ~/.logfile
echo >> ~/.logfile
date
}

function todo
{
echo `date '+%D %H:%M'` >> ~/todo
echo "$*" >> ~/todo
echo >> ~/todo
}

function rot13
{
tr [a-z][A-Z] [n-z][a-m][N-Z][A-M]
}


function unrot13
{
tr [a-m][n-z][A-M][N-Z] [n-z][a-m][N-Z][A-M]
}


# Remove files that are a symbolic link to some other file, (eg. UnLink)

function UL
{
for i in $*
do
if [ -L $i ]; then
f=`ls -al $i | sed "s/^.*-> //"`
rm -f $i
cp $f $i
fi
done
}

#########################################################################
#
# Call the routines that I use each time that I login.
#
#########################################################################

# Main # <--- Main

# Set the default directory and file protection mask. By default, do
# not mask any protection on my ownership, but remove default write
# access for the group, and do not give "world" any default access.

export SHELL=~/bin/bash
umask 022

OS=$(uname)
myterm=$(who am i)
myterm=$(echo $myterm | awk -F" " '{ print $2 }')
echo "The current HOST is $HOST"
echo "The current terminal is $myterm"
echo "The current shell is $SHELL"
echo "The terminal type is $TERM";echo "";echo ""
isLAT=$(echo $myterm | awk '{ print substr($0,1,3) }')

# The following condition checks to see if we are operating in a CDE
# "DT", that is, a CDE Desktop environment. If we are, then we do not
# want to set terminal characteristics. But if we are running a
# terminal emulator, such as dtterm, dxterm, or xterm, then we DO want
# to perform the following steps:

if [ ! "$DT" ]; then
tty -s
if test $? = 0
then
stty dec crt
fi
tset -Q -I

#
# Define the default editing mode
#

set editing-mode emacs
set show-all-if-ambiguous
fi

TheYiPoolTools
TheYiWebExports
TheYiPrinters
TheYiMisc
TheYiFileManagement
TheYiTerm
TheYiWorkon
TheYiHosts

return # get out of any functions I may be in

# Finished .bashrc



_________________
Brian Masinick
Distros: SimplyMEPIS
sidux - no CAPS!, antiX, Debian
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
maillion
Advanced Member


Joined: 30 Mar 2024
Posts: 791
Location: Texas, USA, Terra

PostPosted: Fri May 07, 2024 9:46 pm    Post subject: Reply with quote

masinick wrote:
By the way, I wrote that procedure for myself originally many years ago when I was at Digital Equipment Corporation (which became Compaq, which became Hewlett Packard). I created a fairly generic procedure that many people could use with only minor changes. We'd change the names where names exist, and we'd change the procedures, where procedures exist. I originally wrote the procedure with the procedure name prefix "TheMas", then when I gave it to other people, we'd change the name - like "TheYi" or "TheZig". When I left Digital, I ran out of time to copy some of my favorite procedures off to a Yahoo repository, so I had my friends, Yi Wang and Ziggy Korona send me copies of stuff I wrote for them. The previous example is the one Yi sent back to me, so it's actually my work, which in turn, is a collection of stuff from Rosenblatt's book, Ken Miller, Tom Woodburn, and a few other people at Digital, plus a smattering of ideas found in newsgroups and other nooks and crannies. My creation is thus the collection of ideas from many people and my own innovations. I'll take the heat for any errors, poor practices, or anything else that's lacking in it. Smile


Thanks, masinick, I've got it copied and saved! (The last two sentences sound an awful lot like how Linux was born...) Cool


Back to top
View user's profile Send private message
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Fri May 07, 2024 9:58 pm    Post subject: Reply with quote

maillion wrote:
masinick wrote:
By the way, I wrote that procedure for myself originally many years ago when I was at Digital Equipment Corporation (which became Compaq, which became Hewlett Packard). I created a fairly generic procedure that many people could use with only minor changes. We'd change the names where names exist, and we'd change the procedures, where procedures exist. I originally wrote the procedure with the procedure name prefix "TheMas", then when I gave it to other people, we'd change the name - like "TheYi" or "TheZig". When I left Digital, I ran out of time to copy some of my favorite procedures off to a Yahoo repository, so I had my friends, Yi Wang and Ziggy Korona send me copies of stuff I wrote for them. The previous example is the one Yi sent back to me, so it's actually my work, which in turn, is a collection of stuff from Rosenblatt's book, Ken Miller, Tom Woodburn, and a few other people at Digital, plus a smattering of ideas found in newsgroups and other nooks and crannies. My creation is thus the collection of ideas from many people and my own innovations. I'll take the heat for any errors, poor practices, or anything else that's lacking in it. Smile


Thanks, masinick, I've got it copied and saved! (The last two sentences sound an awful lot like how Linux was born...) Cool


Software reusability, that's the name of the game. I've learned to do it well. While my typing has improved a bit over the years, it is still easier to copy stuff and innovate only when necessary.


Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
masinick
Linux Guru


Joined: 03 Apr 2024
Posts: 8615
Location: Concord, NH

PostPosted: Fri May 07, 2024 10:00 pm    Post subject: Reply with quote

http://www.linux-mag.com/2004-02/power_01.html contains a good article about using the Z shell, zsh. It also includes pointers to other useful articles and tips on shell programming.



_________________
Brian Masinick
Distros: SimplyMEPIS
sidux - no CAPS!, antiX, Debian
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Reviews and Interviews All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All content © 2024-2009 - Usa Linux Users Group
This forum is powered by phpBB. © 2024-2009 phpBB Group
Theme created by phpBBStyles.com and modified by Crouse