cd ~/it244/ex
mkdir ex19
cd ex19
history mechanismhistory
history
The list you see here is every one of your last 500 command lines.
history 10
When you give history a numeric argument, it lists only
that number of commands.
!EVENT_NUMBER
where EVENT_NUMBER is a number you obtained from the history command.
!hhistory Variables
echo $HISTFILE
This is the file that contains your history record.
tail $HISTFILE
echo $HISTFILESIZE
This is the maximum number of command lines the history mechanism will
record in ~/.bash_history when you quit
cat $HISTFILE | wc -l
The wc (word count) command with the -l option
counts the number of lines in the file
given to it as an argument.
echo $HISTSIZE
The value of this variable sets the maximum number of command lines saved
by the history mechanism between individual terminal sessions.
fc to Edit a Commandpwd on the same line
cd ~tsoro ; pwd
fc
fc
The command line you just entered appears in an editing window.
cd ~; pwd; ls
pwd
and list the contents of that directory.
fc -l
fc EVENT_NUMBER
Make some changes save and quit.
history
fc h
Change the command to read
history 5
echo foo; echo bar; echo bletch
↑
Control A
Control E
echo commandecho command
Control K
Control U
cd ~/it244/ex/ex19
mkdir command then hit Tab
mk[Tab]
The terminal should beep.
[Tab]
You should now see a list of all commands that begin with "mk".
mkdir command is complete.
mkdir.
cd ~/it2[Tab] [Enter]
You should now be in your it244 directory.
pwd ; ls
cd ~/it244/e[Tab]
The Readline library adds an "x"
team='Red Sox'
echo $t[Tab][Enter]
blar=green ; bletch=red
echo $b[Tab]
Readline completion adds an l.
[Tab][Tab]Completion shows you the variables that match.
r[Enter]
cd
pwd
nano .bash_profile
export ex=it244/ex
alias ex='cd $ex'
source ~/.bash_profile
ex
pwd
You should be in your ex directory inside your
it244 directory.
cd
nano .bash_profile
alias h='history 10'
alias hg='history | grep '
source .bash_profile
h
You should see your last 10 command lines.
hg cd
You should see every time you have run cd in the last
500 command lines.
city=Boston
echo $city
capitol='$city is the capitol of Massachusetts'
echo $capitol
The variable city is not evaluated because it was enclosed in
single quotes when defined.
capitol="$city is the capitol of Massachusetts"
echo $capitol
The double quotes permitted the shell to evaluate city when
assigning a value to capitol.
cd
echo $PWD
PWD has the address of your home directory.
cd ~tsoro
echo $PWD
PWD is now set to the address of my home directory.
alias new_pwd="echo $PWD"
new_pwd
It displays the address of my home directory.
cd
pwd
new_pwd
The alias again returns the address of my home directory.
alias new_pwd='echo $PWD'
new_pwd
It displays the address of your home directory.
cd ~tsoro
new_pwd
It displays the address of my home directory.
cd
nano
nano .bash_profile
cheer ()
{
echo Go $1'!'
}
print_args ()
{
echo "arg1: $1"
echo "arg2: $2"
echo "arg3: $3"
}
source ~/.bash_profile
cheer 'Red Sox'
print_args foo bar bletch