home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
264b.lha
/
butils
/
xargs.doc
< prev
next >
Wrap
Text File
|
1989-07-09
|
4KB
|
101 lines
XARGS 1.3 by Bill Dimm
USAGE:
xargs [options] "expression" [files]
DESCRIPTION:
Xargs takes a list of arguments and merges them with the expression
in order to form a string which is executed as an AmigaDOS command (thus,
shell commands cannot appear in expression). If files
are supplied the list is read from the files (blank lines ignored),
otherwise the list is read from standard input. Options:
-t trace mode, expressions are echoed to stderr before execution
-p prompt mode, auto trace, and prompts on whether or not to
execute echo expression
-i insert mode, each argument is inserted where {} is located in
the expression (-n & -s settings are ignored when using
insert mode)
-e ignore errors, arguments will continue to be processed even
if an error occurs
-n num pass a max of num arguments to each expression (default 9)
-s size pass of max of size characters per expression (default 255)
It is important to note that xargs does not enclose each argument
in quotes, so if you have arguments which contain spaces you should be
careful (enclose them in quotes). When not in insert mode, arguments are
appended to the end of the expression before it is executed.
IMPROVEMENTS:
Since version 0.9, a bug which caused an empty expression to be
executed sometimes has been removed. Since it is sometimes necessary to
enclose an argument in quotes (because it contains spaces), version 1.0
allows its command line arguments to be enclosed in single quotes (') instead
of double quotes. If you choose to enclose the expression in single quotes
you may include normal quotes in the expression. If you are using shell, be
ware that arguments which are enclosed in single quotes instead of double quotes
are not protected from the shell preprocessor, so special characters (such
as " or *) should be preceded by a backslash (\). Unix fans beware, the
rolls of single and double quotes in shell (using xargs) are the opposite
of what they are in Unix (this cannot easily be overcome). The -e option was
added.
Since version 1.0, xargs has been given the ability to execute
multiple commands for each argument. This can only be done when using
the -i option. Simply place semi-colons between the commands in the
expression. Xargs will not consider a semi-colon which is preceded by a
backslash a command separator. Shell users, don't forget that ; is
special to the shell (& should be preceded by a \ which is not seen by xargs)
See the last example.
Since version 1.1, xargs has been recompiled with Lattice 5.0.
When in trace mode, it now prints the commands that it is going to
execute in a different color so that it can be distinguished from the
output of the command.
Since version 1.2, a bug which allowed the '-i' to overflow
the buffer has been removed. A line which is too long to
construct with '-i' is now reported as an error. Also, the default
for '-s' has been increased from 250 to 255.
EXAMPLES:
objective - to print (to prt:) out all of the files ending with .doc on
a disk (filenames may contain spaces)
This example assumes that you have the find command, which allows you to
generate a list of all files on a disk matching a certain pattern.
AmigaDOS solution:
find >ram:tmp -f *.doc -p df0:
xargs -i 'type "{}" to prt:' ram:tmp
Shell solution:
find -f "*.doc" -p df0: | xargs -i 'type \"{}\" to prt:'
Notice the quotes around the {} to keep a filename with spaces from looking
like two different files when xargs passes it to AmigaDOS.
Here is an example of multiple commands to rename files from DF0: to df1:
xargs -i "copy DF0:{} df1: ; delete df0:{}" ram:FileList
Here is a very easy way to grep all '.c' files for the word 'VERSION'
AmigaDOS solution:
find >ram:tmp -f *.c -p DATA:
xargs "grep VERSION" ram:tmp
Shell solution:
find -f "*.c" -p data: | xargs "grep VERSION"
TRAILING NOTE: The "shell" mentioned above is Matthew Dillon's shell.