Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!snorkelwacker!ira.uka.de!fuchs From: fuchs@it.uka.de (Harald Fuchs) Newsgroups: comp.misc Subject: Re: [] in Unix filenames Message-ID: Date: 19 Sep 90 23:15:09 GMT References: <9009191420.AA10971@thep.lu.se> Sender: news@ira.uka.de (USENET News System) Organization: University of Karlsruhe, FRG Lines: 41 magnus@THEP.LU.SE (Magnus Olsson) writes: >OK, I thought, I;ll just use the mved script published here some time >ago and do >mved \[*\]= = >(the = is a special wildcard recognized by mved - the command would mean >the same as >mv \[.subdir\]file1 file1 >etc.) >But to my surprise, the shell just said "[: no such file or directory". >Actually, I couldn't find out *any* combination of backslashes and or quotes >that enabled me to get what I wanted (what [*] would have meant if [] weren't >special characters). >Finally, I gave up and wrote a C program to do the job. I use a tool called 'rename' for tasks like this: rename 's/\[\.subdir\]//' \[* And here's 'rename': #!/usr/local/bin/perl $0 =~ s:.*/::; die "Usage: $0 action file...\n" unless $#ARGV > 0; $op = shift; for (@ARGV) { $was = $_; eval $op; die $@ if $@; if ($was ne $_) { rename ($was, $_) || die "$0: can't rename $was to $_: $!\n"; } } What? You don't have perl? Ask your next friendly FTP site... -- Harald Fuchs