lecture 7 l.
Download
Skip this Video
Download Presentation
Lecture 7

Loading in 2 Seconds...

play fullscreen
1 / 17

Lecture 7 - PowerPoint PPT Presentation


  • 437 Views
  • Uploaded on

Lecture 7. directory and file control your programming environment loops. Recording your screen interactions. [ fitzpatricke@baboon ~]$ script Script started, file is typescript sh-3.00$ cd lex.growth sh-3.00$ ./lexy.loop alice30.txt sh-3.00$ more stats.loop xaa.out 1893 xab.out 761

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Lecture 7' - Jimmy


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
lecture 7

Lecture 7

directory and file control

your programming environment

loops

recording your screen interactions
Recording your screen interactions

[fitzpatricke@baboon ~]$ script

Script started, file is typescript

sh-3.00$ cd lex.growth

sh-3.00$ ./lexy.loop alice30.txt

sh-3.00$ more stats.loop

xaa.out 1893

xab.out 761

xac.out 539

xad.out 407

sh-3.00$ exit

exit

Script done, file is typescript

the file typescript
The file typescript

Script started on Mon Oct 31 14:13:17 2005

sh-3.00$ cd lex.growth

sh-3.00$ ./lexy.loop alice30.txt

rm: cannot remove `x*': No such file or directory

rm: cannot remove `*.out': No such file or directory

sh-3.00$ more stats.loop

xaa.out 1893

xab.out 761

xac.out 539

xad.out 407

sh-3.00$ exit

exit

Script done on Mon Oct 31 14:13:46 2005

[ Read 14 lines ]

^G Get Help ^O WriteOut ^R Read File ^Y Prev Pg ^K Cut Text ^C Cur Pos

^X Exit ^J Justify ^W Where is ^V Next Pg ^U UnCut Text^T To Spell

your programming environment dotfiles
Your Programming Environment- Dotfiles -

ls -ashow files that determine your programming environment at login

. .bash_profile

.. .bashrc

.Xdefaults .screenrc

.bash_history

.bash_logout

the alias
The alias
  • Aliasing allows you to call one thing another thing
  • example:

alias guten='cd /home/data/text.data/gutenberg'

changing rm in your bash profile
Changing rm in your .bash_profile

cd

ls -a

cp .bash_profile .bash_profile.bak

pico .bash_profile

alias rm =‘rm -i’

:w

:q

. .bash_profile

directory file control system utilities
Directory & File Control(System Utilities)

cd change directory

pwd print working directory

mkdir dn make a directory, call it ‘dn’

ls -l -t list long list list by time

cp fn1 fn2 copy fn1 to fn2

chmod o+w fn allow others to write to fn

history show all past commands

slide8
echo
  • echoes its arguments on the screen:

echo Hello world

Hello world

  • handy for checking shorthand characters

echo chap*

chap1 chap2 chap3

echo chap[1-2]

chap1 chap2

environment variables
Environment variables

.bash_profile

contains variables that set up your environment

$HOME

stores the pathname of your home directory

$PATH

stores the list of directories to search for programs

slide10
$PATH

/usr/kerberos/binbaboon sys admin progs

/usr/local/bin nothing there!

/bin progs you will recognize

/usr/bin machine stuff

/usr/X11R6/bin X windows stuff

/home/your_username/bin Directory for your programs

variables you know and love
Variables you know (and love?)

$HOME

$PATH

$0, $1, $2

Moral: variables begin with a dollar sign

putting a loop in a shell script
Putting a loop in a shell script
  • a loop is used to execute the same command(s) repeatedly
  • Syntax of a for loop

for variable in list

do

command(s) including $variable

done

sample looping over a list
Sample looping over a list

#!/bin/bash

#riders

#generate a child’s nursery rhyme

for people in gentleman lady farmer

do

echo This is the way the $people rides

done

output of sample loop
Output of sample loop

$riders

This is the way the gentleman rides

This is the way the lady rides

This is the way the farmer rides

looping over a list of files
Looping over a list of files

ls /home/lucent/wangx/ubdb/*.in

TP001.in TP049.in

TP002.in

TP003.in

TP004.in

TP005.in

TP006.in

TP007.in

looping over a list of files 2
Looping over a list of files (2)

#!/bin/bash

for file in /home/lucent/wangx/ubdb/*.in

do

tail $file >> tail.in

done

output of loop over files
problem

pcl 3.727632

p 3.757441

r 3.8198171

"_o 3.934128

bcl 4.0380421

b 4.0380421

l 4.0597081

& 4.1383228

m 4.178987

,

* 4.5711851

children

Ccl 4.6082158

C 4.7256999

"_i 4.827867

l 4.8504529

dcl 4.8852291

d 4.9105291

r 4.950274

& 5.0135241

n 5.0482998

,

* 5.5064631

Output of loop over files