CS 330 Lecture 2 – Shell Scripts and Redirection
January 25, 2013 by Chris Johnson. Filed under
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
cs330, lectures, spring 2013.
Agenda
- shell builtin variables
- interpolation
- custom variables
- reusing output
- meday
- custom scripts
- PATH
- permissions
- change extension 1+ files at a time
- command-line arguments
- resizing a bunch of images with convert
- checking for mail
- STDIN and STDOUT and STDERR
- output redirection
- pipes
- subshells
The Unix way
Doug McIlroy said:
This is the Unix philosophy: Write
programs that do one thing and do it well. Write programs to work together. Write programs to handle
text streams, because that is a universal interface.
TODO
- Read section Learning the Shell at http://linuxcommand.org/index.php.
- Bring a quarter sheet with two questions and two observations to class.
- Log in to thing-[012] and write your own shell script to do something.
Code
doeday
#!/bin/sh
cal 28 3 $(date +%Y)
imagen
#!/bin/sh
convert -size 1600x1200 plasma: plasma.JPG
convert -size 1600x1200 plasma:blue blue.JPG
convert -size 1600x1200 plasma:tomato-steelblue tomatoblue.JPG
convert -size 1600x1200 plasma:grey50-grey50 plasma-grey.JPG
convert -size 1600x1200 gradient: grad.JPG
convert -size 1600x1200 gradient:yellow ygrad.JPG
convert -size 1600x1200 radial-gradient: cgrad.JPG
fixext
#!/usr/bin/env zsh
for file in $*; do
mv $file ${file:r}.jpg
done
Haiku
Out is the new in
Only cool in the shell though
Don’t eat human waste