The bash and C shell curly brace operators ( 9.5 ) are handy for working with strings. Some versions of the Korn shell can be configured to make these work. [2] If your Korn shell can't do that, or if you use the Bourne shell, you can use the shell function ( 10.9 ) called qcsh . (You can rewrite it as a shell script ( 44.2 ) if your shell doesn't have functions.) It writes the command line you type into a temporary file, then gives the file to the C shell. [3] Type qcsh , a space, and the command line you want to run. Here are two examples from article 9.5 : to fix a typo in a filename (change fixbold61.c to fixbold6.c ):
[2] If your system has Korn shell sources, your system administrator can edit the file OPTIONS and set
BRACEPAT=1
, then recompile.[3] In some versions of UNIX, passing the command line to the C shell with
csh
-fc
"$@"
wouldn't expand the braces. That's why I used a temporary file.
$qcsh mv fixbold{61,6}.c
To edit ten new files that don't exist yet:
$qcsh vi /usr/foo/file{a,b,c,d,e,f,g,h,i,j}
Here's the function:
-f |
qcsh() { echo "$@" > /tmp/q$$ csh -f /tmp/q$$ rm -f /tmp/q$$ } |
---|
-