ラベル Learning the bash shell の投稿を表示しています。 すべての投稿を表示
ラベル Learning the bash shell の投稿を表示しています。 すべての投稿を表示

2012年8月23日木曜日

3.4.2.4 Command search path

Why you should care about path?
  1. Once you have read the later chapter of this book and  you try writing your own shell program, you will want to test them and eventually set aside a directory for them.
  2. Your system may be set up so that certain restricted commands' executable files are kept in directories that are not listed in PATH
Add directory to PATH:put this line to .bash_profile
PATH=$PATH":/home/you/bin/"

HISTTIMEFORMAT

3.4.2. Build-in Variables
3.4.2.1. Editing mode variables

HISTTIMEFORMAT="%y/%m/%d %T "

...
78 04/11/26 17:14:05 HISTTIMEFORMAT="%y/%m/%d %T "
79 04/11/26 17:14:08 ls -l
80 04/11/26 17:14:09 history

echo "$HISTTIMEFORMAT"
%y/%m/%d %T

Learning the bash

Ch. 1 bash Basics

Ch. 2 Command-Line Editing
  • emacs, vi editer
  • 2.2. The History List
  • emacs Editing Mode
  • vi Editing Mode
  • The fc Command
    fc is a built-in shell command that provides a superset of the C shell history mechanism. You can use it to examine the most recent commands you entered, to edit one or more commands with your favorite "real" editor, and to run old commands with changes without having to type the entire command in again.
Ch. 3 Customizing Your Environment
  • Special files: .bash_profile, .bash_logout, and bashrc
  • Aliases:
    aliase name='command'
    aliase search=grep
    aliase cdvoy='cd sipp/demo/animation/voyager'

    * just alias show all aliases
    *unalias remove alias
    Aliases are very handy for creating a comfortable environment, but they have essentially been superseded by shell scripts and functions, which we will look at in the next chapter. These give you everything aliases do plus much more, so if you become proficient at them, you may find that you don't need aliases anymore. However, aliases are ideal for novices who find UNIX to be a rather forbidding place, full of terseness and devoid of good mnemonics. Chapter 4 shows the order of precedence when, for example, an alias and a function have the same name. 
  • Options:
    shopt -o :
  • Variables: Shell variables are characteristics which cannot be expressed as an on/off choise.
    varname=value
    • 3.4. built-in variables
      HISTCMD
      HISTFILESIZE
      HISTSIZE
    • 3.4.2.2. Mail variables
      Since the mail program is not running all the time, there is no way for it to inform you when you get new mail; therefore the shell does this instead.
    • 3.4.2.3 Prompting variables
      PS1, PS2, PS3, PS4
    • 3.4.2.4 Command search path

Ch. 4 Basic shell Programming
  • Shell Scripts and Shell Functions

Ch. 5 Flow Control
Ch. 6 Command-Line Options and Typed Variables
Ch. 7 Input/Output and Command-Line Processing
Ch. 8 Process Handling
Ch. 9 Debugging Shell Programs
Ch. 10 bash Administration
Ch. 11 Shell Scripting
Ch. 12 bash for Your System

Appx. A. Related Shells
Appx. B. Reference Lists
Appx. C. Loadable Built-Ins
Appx. D. Programmable Completion

2012年8月20日月曜日

Summary of Bash features

Summary of Bash features
bash is a backward-compatible evolutionary successor to the Bourne shell that includes most of the C shell's major advantages as well as features from the Korn shell and a few new features of its own. Features appropriated from the C shell include:
  • Directory manipulation, with the pushd, popd, and dirs commands.
  • Job control, including the fg and bg commands and the ability to stop jobs with CTRL-Z.
  • Brace expansion, for generating arbitrary strings.
  • Tilde expansion, a shorthand way to refer to directories.
  • Aliases, which allow you to define shorthand names for commands or command lines.
  • Command history, which lets you recall previously entered commands.
bash's major new features include:
  • Command-line editing, allowing you to use vi- or emacs-style editing commands on your command lines.
  • Key bindings that allow you to set up customized editing key sequences.
  • Integrated programming features: the functionality of several external UNIX commands, including test, expr, getopt, and echo, has been integrated into the shell itself, enabling common programming tasks to be done more cleanly and efficiently.
  • Control structures, especially the select construct, which enables easy menu generation.
  • New options and variables that give you more ways to customize your environment.
  • One dimensional arrays that allow easy referencing and manipulation of lists of data.
  • Dynamic loading of built-ins, plus the ability to write your own and load them into the running shell.