LAB02Spring2012

LAB02Spring2012 - output and error Using pipes to pass data...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 252 SPRING 2012
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
LAB 02 SHELL SCRIPTING
Background image of page 2
Shell Scripting Basics Basic constructs Printing messages Common commands Variables Arithmetic manipulation of variables Environment Variables Looping Constructs and Conditionals
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Printing Messages : - echo Common commands (I use) : top uptime du df ps The more common lot : ls, pwd, dirname, basename, date, clear, cd, chmod
Background image of page 4
Variables <variable name>=value Referred with a '$' in front of the name Using expr set and environment variables : $HOME, $SHELL, $HOSTNAME Command line arguments to a script : $1, $2 Other special variables : $?, $#, $@
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Looping Constructs and Conditionals if for while “[“ “]” Redirecting input,
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: output and error. Using pipes to pass data between commands and/or programs Writing scripts in a file, running them TASK ● ● ● Backup Script Use ls-lR to get directory contents with modification times, monitor for changes backupd.sh dir backupdir interval-secs max-backups Algorithm: ls -lR > ls-lR.last copy the directory dir into backupdir/<current-date> while (1) { sleep interval-secs ls -lR > ls-lR.new diff ls-lR.new ls-lR.last if (if they are different) { copy the directory dir into backupdir/<current-date> mv ls-lR.new ls-lR.last } } ● ● Please follow the turnin instructions on the handout The programming assignment is due on the 11:00am Jan 31, 2012 ALL THE BEST :)...
View Full Document

Page1 / 10

LAB02Spring2012 - output and error Using pipes to pass data...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online