Features of the TCSH Shell

LG #35

Many operations in the shell work on many files, e.g., all files ending with .tex or starting with test-. TCSH has the ability to type all these files for you, with file patterns. The following list shows which possibilities exist:


Match any number of characters


Match a single character


Match any single character in the list


Match any character within the range of characters from x to y


Match elements which do not match the list


This expands to all the words listed. There's no need that they match


^ in the beginning of a pattern negates the pattern

  • *.tex: match all files ending with .tex

  • ^*.tex: match all files which does not end with .tex

  • xxx{ab,cde,hifj}yy: match xxxabyy xxxcdeyy and xxxhifjyy

  • *.[ch] or *.{c,h}: match all .c and .h files

The Shell Expand Patterns

An important thing to be aware of is that it is the shell which expands the patterns, and not the program, which is executed with the pattern.

An example of this is the program mcopy which copies files from disk. To copy all files, you may wish to use a asterisk, as in: mcopy a:* /tmp. However, this does not work, since the shell will try to expand the asterisk. Since it cannot find any files which start with a:, it will signal an error. So if you wish to send a asterisk to the program, you have to escape the asterisk: mcopy a:\* .

There are two very useful key bindings which can be used with patterns. The first is C-xg, which lists all the files matching the pattern, without executing the command. The other is C-x*, which expands the asterisk on the command line. This is especially useful if you wish to delete all files ending in .c except important.c, stable.c and another.c. Creating a pattern for this might be very hard, so just use the pattern *.c. Then type C-x*, which will expand *.c to all your .c files. Now it's easy to remove the three files from the list.


When using the shell, you will soon recognize that certain commands are typed again and again. One of the top ten is surely ls -la, which lists all files in a directory in long form.

TCSH has a mechanism to create aliases for commands. This means that you can create an alias for ls -la called la.

Aliases may refer to the arguments of the command line. This means that you can create a command called pack which takes a directory name and packs the directory with tar and gz.

Aliases can be a bit hard to create since you often want history/variable references expanded at the time of use, not at the definition time. This can be done more easily with TDG; go to the page aliases to define aliases. If you end up with an alias you cannot define on this page, but you can in TCSH, please send me e-mail (blackie@imada.ou.dk). For more information about aliases, see the TCSH manual at http://www.imada.ou.dk/Technical/Manpages/tcsh/Alias_substitution.html.

Timing Programs

Have you ever needed to know how long a program took to run, i.e., how much CPU it used? If so, you may recognize the output from the TCSH built-in time command:

0.020u 0.040s 0:00.11 54.5%     0+0k 0+0io 21pf+0w

Informative? Yes but... the GNU time command is a bit more understandable:

0.01user 0.08system 0:00.32elapsed 28%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+0minor)pagefaults 0swaps
In TDG you can configure the output from the time command on the page called jobs shown in Figure 5.

Figure 5. TDG Jobs Page


As you may have guessed, TDG and this article will help you a lot in the use of TCSH, but you may need to read a bit more to get even more out of TCSH. Here are a few references:

  • The TCSH manual page at http://www.imada.ou.dk/Technical/Manpages/tcsh/top.html

  • Using csh & tcsh by Paul DuBois, published by O'Reilly & Associates, 1995: http://www.primate.wisc.edu/software/csh-tcsh-book/

  • The TCSH mailing list at tcsh@mx.gw.comr (to join send mail to listserv@mx.gw.com with body text SUBscribe TCSH your name)

Jesper Pedersen lives in Odense, Denmark, where he has studied computer science at Odense University since 1990. He is a system manager at the university and also teaches computer science. He is very proud of his “child”, The Dotfile Generator, which he wrote as part of his job at the university. In his spare time, he does Jiu-Jitsu, listens to music, drinks beer and has fun with his girlfriend. He loves pets, and has a 200 litre aquarium and two very cute rabbits. His home page can be found at http://www.imada.ou.dk/~blackie/“, and he can be reached at blackie@imada.ou.dk. This article first appeared in Issue 12 of Linux Gazette.


White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState