Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Filename Generation (again)
- X-seq: zsh-users 11650
- From: jadamson@xxxxxxxxxxxx (Joel J. Adamson)
- To: zsh-users@xxxxxxxxxx
- Subject: Filename Generation (again)
- Date: Mon, 16 Jul 2007 14:20:05 -0400
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
Howdy List,
I wrote in about this filename generation a while ago. I used a
suggestion from Peter Stephenson, and I thought that it worked, but
now I'm getting the same "no matches found".
As before, I get different behavior from within the doit() function
and at the command line. In other words, I use this globbing pattern
found in the second line of the function doit() and I get the files I
want. The script, however returns
----------------------------------------
doit:1: no matches found: /home/joel/data/*generic*~*~
----------------------------------------
Since the script is short, I'll post the whole thing:
----------------------------------------
#!/bin/zsh
#script to set up new data directory
# $Author$
# $Revision$
# $Date$
# this script needs some setup conditions that will help it to do its job
# 1. establish the current path
# 2. if options are blank or "help" is the only argument, then
# print a terse help message
doit () {
for file in $1/*generic*~*\~ # help from Peter Stephenson
do
filename=${file##$1}
newfilename=${filename/\/generic/$title}
cp $file ./$newfilename
ci -m'new analysis' -u -zLT $newfilename
done
if [[ -a ${title}Makefile ]]; then
mv ./(generic|$title)Makefile ./Makefile
else
print No Makefile found
fi
if [[ -a $1/data/wilens.bib ]]; then
ln -s $1/data/wilens.bib
fi
exit 0
}
if [[ $1 == *help* || -z $1 ]]; then
print "DataDir v1.0
Usage: datadir -n new subdirectory [-o source for files] -t title for new analysis
See 'man datadir' for more information"
exit 1
else
local opt # process options: n = new directory
# t = title: new string for filenames
while getopts n:o:t: opt; do
case $opt in
(n) new=$OPTARG;; # long options?
(o) old=$OPTARG;;
(t) title=$OPTARG;;
esac
done
if [[ -d $new || -a $new ]]; then
print File or directory $new exists # this should probably do more, like
exit 1 #ask for a new name
else
mkdir -p $new
fi
# now the magic:
cd $new
mkdir RCS
umask gu+rw
if [[ -n `find $old -iregex ".*generic.*[^~]"` ]]; then # what if
# $old is not set?
age=$old
elif [[ -n `find $HOME/data/ -iregex ".*generic.*[^~]"` ]]; then
# default location for generic files
age=$HOME/data
fi
doit $age
fi
----------------------------------------
Thanks for any help,
Joel
--
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA 02114
(617) 643-1432
(303) 880-3109
*Getting unexpected output from Word?
http://www.youtube.com/watch?v=9sZtriK9rKQ&NR=1
*Try LaTeX: it's free, easy and professional
http://www.edafe.org/latex/
http://en.wikipedia.org/wiki/LaTeX
http://nitens.org/taraborelli/latex
The information transmitted in this electronic communication is intended only for the person or entity to whom it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this information in error, please contact the Compliance HelpLine at 800-856-1983 and properly dispose of this information.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author