[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

AB.8 Shell Commands in Dired

The Dired command ! (dired-do-shell-command) reads a shell command string in the minibuffer and runs that shell command on all the specified files. X is a synonym for !. You can specify the files to operate on in the usual ways for Dired commands (see section AB.7 Operating on Files). There are two ways of applying a shell command to multiple files:

What if you want to run the shell command once for each file, with the file name inserted in the middle? You can use `?' in the command instead of `*'. The current file name is substituted for `?'. You can use `?' more than once. For instance, here is how to uuencode each file, making the output file name by appending `.uu' to the input file name:

 
uuencode ? ? > ?.uu

To use the file names in a more complicated fashion, you can use a shell loop. For example, this shell command is another way to uuencode each file:

 
for file in *; do uuencode "$file" "$file" >"$file".uu; done

The working directory for the shell command is the top-level directory of the Dired buffer.

The ! command does not attempt to update the Dired buffer to show new or modified files, because it doesn't really understand shell commands, and does not know what files the shell command changed. Use the g command to update the Dired buffer (see section AB.14 Updating the Dired Buffer).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 2, 2002 using texi2html