[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mv *.lisp *.lsp on unix



defsys.lisp states:

;;; When you get a copy of PCL (by tape or by FTP), the sources files will
;;; have extensions of ".lisp" in particular, this file will be defsys.lisp.
;;; The preferred way to install pcl is to rename these files to have the
;;; extension which your lisp likes to use for its files.  Alternately, it
;;; is possible not to rename the files.  If the files are not renamed to
;;; the proper convention, the second line of the following defvar should
;;; be changed to:
;;;     (let ((files-renamed-p nil)
;;;
;;; Note: Something people installing PCL on a machine running Unix
;;;       might find useful.  If you want to change the extensions
;;;       of the source files from ".lisp" to ".lsp", *all* you have
;;;       to do is the following:
;;;
;;;       % foreach i (*.lisp)
;;;       ? mv $i $i:r.lsp
;;;       ? end
;;;       %
;;;
;;;       I am sure that a lot of people already know that, and some
;;;       Unix hackers may say, "jeez who doesn't know that".  Those
;;;       same Unix hackers are invited to fix mv so that I can type
;;;       "mv *.lisp *.lsp".
;;;

This got me thinking and i came up with the following csh hack that i've
been using for the past few months.  It lets you say things like

"bulk mv *.lsp *.lisp" to move a bunch of files or

"bulk cmp old/*.lsp new/*.lisp" to compare files.


To use it:

in your .cshrc file add the line:

alias bulk set noglob \; ~/bin/bulk \!\* \; unset noglob

in the file ~/bin/bulk put

----- Start ~/bin/bulk -----
: bulk operation source-file-spec [ sink-file-spec ]
: example: bulk mv '*.l' '*.lsp'

: expand ~ for csh here.
source1=`echo "$2" | sed "s/\./\\./g
s;^~;$HOME;
s;/;\\\\\\/;g
s/[*?][*?]*/\\\\\\(.*\\\\\\)/"`

source2=`echo "$2" | sed "s;^~;$HOME;
s;/;\\\\\\/;g
s;[*?][*?]*;\\\\\\1;"`

sink=` echo "$3" | sed "s;^~;$HOME;
s;/;\\\\\\/;g
s/[*?][*?]*/\\\\\\1/"`

: csh treats # as a comment
echo ls "$2" | $SHELL | sed -n "s/#/\\\\#/g
s@$source1@$1 '$source2' $sink@p" | sh -v

----- End ~/bin/bulk ---