home *** CD-ROM | disk | FTP | other *** search
-
- Foreach - Deluxe
- ================
-
- Version 1.0
- (31.3.94)
-
-
- This foreach-command makes it possible to use commands, that don't
- support any pattern-matching (like 'rename'). I am sure that you
- will not want to miss this powerful command again in future.
-
-
- Synopsis:
- ---------
-
- foreach <pattern> <command>
-
-
- Introduction:
- -------------
- I think the best way to learn the command is to demonstrate it
- first with some examples to allow you to see how the command works:
-
-
- - Display all files ending with .c using 'more':
-
- foreach #?.c more &
-
- In this case the pattern is #?.c . The command will now be called
- for each file that matches the pattern, replacing the '&'-character
- with the filename each time.
-
-
- - Unarchive all #?.lha und #?.lzh files into the RamDisk:
-
- foreach #?.(lha|lzh) lha x & ram:
-
-
- - Replace the suffixes .lzh with .lha on all files:
-
- foreach #?.lzh rename & &<.lha
-
- This is new! The token '&<' will (unlike the plain '&') expand to the
- filename without the suffix.
-
-
- - Copying a file three times:
-
- foreach {copy1,copy2,copy3} copy source &
-
- Produces three copies with the names copy1,copy2 and copy3.
-
-
- - Compiling of all #?.cc files with gcc:
-
- foreach #?.cc gcc $
-
- Please note that the '$'-character will expand to all matching files
- unlike '&', which expands to only one of the matching files each time.
- Accordingly only one command will be generated, that could look like
- this: ( gcc file1.cc file2.cc file3.cc )
-
-
-
- reference:
- ----------
-
- & - will be replaced with a string matching the pattern (eg. a filename)
- in each command that will be generated.
-
- &< - like '&', but this time the suffix will be cut off (the last suffix
- if there are more than one dots). If there is no dot in the name,
- the complete string will be used (like '&').
-
- &> - like '&', but this time only the suffix without the filename. If
- there is no suffix, an empty string (not even a space) will be used.
-
- $ - will be replaced with all matching strings at the same time,
- separated with a space between each of them (no space at the
- beginning and ending).
-
- && - will be replaced with a single '&'-character.
-
- % - will be replaced with an empty string.
-
-
-
- notes:
- ------
-
- - There may even be empty strings in the set-argument. For example:
- {} or {aaa,aa,a,}.
-
- - Mind that you have to place quotation marks around the set if it
- contains any string with spaces, as the command-line parser cuts
- the arguments at spaces:
- wrong: {James,Judy,Mr Bean}
- right: "{James,Judy,Mr Bean}"
-
- - As soon as there is at least one '&'-character in the command string,
- several independent commands will be generated. (ie. are there only
- '$'-characters in the command string, only one command will be
- generated).
-
-
- hints:
- ------
-
- - It is possible to chain several 'foreach'-commands making the
- 'foreach'-command even more powerful.
-
- Example: Creating two backups of all #?.c files:
-
- foreach #?.c foreach {bak1,bak2} copy & &<.&&
-
- Note that the first 'foreach' replaces the '&&' to a singe '&'.
- The second 'foreach' will look like this:
- foreach {bak1,bak2} file1.c file1.&
-
-
- - The '%'-character's main purpose is to solve ambiguities.
- E.g.: You want to write a string two times without any spaces in
- between:
- wrong: foreach {hello,hi,goodmorning} echo &&
- right: foreach {hello,hi,goodmorning} echo &%&
-
-
- Copyright:
- ----------
- This program is public domain. It may be copied only if the program and
- this manual have not be modified in any way. The program must never be
- copied without the manual.
- The program must not be sold or included in a commercial product without
- my permission (write or EMail me).
-
-
- Dirk Farin
- Kapellenweg 15
- 72070 Tübingen
- Germany
-
- EMail: farindk@trick.informatik.uni-stuttgart.de
-
-
- I would be happy to receive any bug-reports andideas for future versions!
-
-
-
-
-
-