apply(1) General Commands Manual apply(1)NAME
apply - Applies a command to a set of arguments
SYNOPSIS
apply [-acharacter] [-number] command argument...
The apply command runs the specified command on each argument in turn.
OPTIONS
Identifies the character used instead of the % (percent sign) to designate argument substitution strings. Specifies the number of argu-
ments to be passed to command.
DESCRIPTION
Normally, arguments are chosen individually; the optional number specifies the number of arguments to be passed to command. If number is 0
(zero), command is run without arguments once for each argument.
If you include character sequences of the form %n (where n is a digit from 1 to 9) in command, they are replaced by the nth unused argument
following command when command is executed. If any such sequences occur, number is ignored, and the number of arguments passed to command
is the maximum value of n in command.
You can specify a character other than % (percent sign) to designate argument substitution character strings with the -a option; for exam-
ple, -a@ would indicate that the sequences @1 and @2 were to be replaced by the first and second unused arguments following command.
NOTES
Shell metacharacters in command may have undesirable effects; it is best to enclose complicated commands in ' ' (single quotes).
There is no way to pass a % (percent sign) followed immediately by any number if % is the argument expansion character.
EXAMPLES
The following command is similar to ls: apply echo * The following command compares the file a1 to the file b1, a2 to b2, and so on: apply
-2 cmp a1 b1 a2 b2 ... The following command runs who 5 times: apply -0 who 1 2 3 4 5 The following command links all files in the current
directory to the directory /usr/joe: apply 'ln %1 /usr/joe' *
SEE ALSO
Commands: sh(1), xargs(1)apply(1)
Check Out this Related Man Page
APPLY(1) BSD General Commands Manual APPLY(1)NAME
apply -- apply a command to a set of arguments
SYNOPSIS
apply [-a c] [-d] [-#] command argument ...
DESCRIPTION
The apply utility runs the named command on each argument argument in turn.
Character sequences of the form ``%d'' in command, where 'd' is a digit from 1 to 9, are replaced by the d'th following unused argument. In
this case, the largest digit number of arguments are discarded for each execution of command.
The options are as follows:
-# Normally arguments are taken singly; the optional number -# specifies the number of arguments to be passed to command. If the number
is zero, command is run, without arguments, once for each argument.
If any sequences of ``%d'' occur in command, the -# option is ignored.
-a c The use of the character '%' as a magic character may be changed with the -a option.
-d Display the commands that would have been executed, but do not actually execute them.
ENVIRONMENT
The following environment variable affects the execution of apply:
SHELL Pathname of shell to use. If this variable is not defined, the Bourne shell is used.
EXAMPLES
apply echo a*
is similar to ls(1);
apply -2 cmp a1 b1 a2 b2 a3 b3
compares the `a' files to the `b' files;
apply -0 who 1 2 3 4 5
runs who(1) 5 times; and
apply 'ln %1 /usr/joe' *
links all files in the current directory to the directory /usr/joe.
FILES
/bin/sh default shell
AUTHORS
Rob Pike
BUGS
Shell metacharacters in command may have bizarre effects; it is best to enclose complicated commands in single quotes ('').
HISTORY
The apply command appeared in 4.2BSD.
BSD April 4, 1994 BSD
Hi there,
I am trying to move around 3000 files from one directory to another. The mv command is complaining from too many arguments. I tried to use the xargs command but with no luck. Could some body provide help?
Regards (4 Replies)
Hi all,
How many arguments can we pass while testing a prgm at command line..
I encountered an issue while passing 10 arguments.
For $10 its taking argument passed for $1 followed by 'zero'.
can we pass more than 9 arguments /Is there any other way.
Thanks,
rrs (6 Replies)
Dear Freinds,
Help needed in input redirection .
My problem is as follows..
I have a shell script as follows which calls another gnuplot script .
datagen.sh
#!/bin/ksh
gnuplot plot_I.plt
In the above file I am calling another file called plot_I.plt which reside in the same... (4 Replies)
Hi,
What is the maximum number of arguments that could be passed to zsh ?
To find out that I tried a simple script.
And the maximum number of arguments that could be passed turned out to be 23394
#! /bin/zsh
arg=1
i=1
subIndex=23000
while
do
arg=$arg" "$i
i=$(($i + 1))... (9 Replies)
context:
while reading tutorial on the read command, one of the first examples, demonstrating its use, follows as such:
$ x=abc ; printf "x is now '%s'. Enter new value: " $x ; read x
generating this output:
x is now 'abc'. Enter new value:
first, what does %s represent? I know... (3 Replies)
I need to set up a strange system through which an arbitrary command is sent to a number of different servers (well, actually, VPS accounts). We have a command "vpass" that "passes" a command from the root level to resident VPS accounts. Suppose I wanted each VPS to do some trivial thing, like... (3 Replies)
Hi Guys,
I am trying to pass arguments to the script i am wrinting.
When no argument is passed or wrong argument is passed, the script needs to output the way it needs to be called and exit.
Currently, when no arguments is passed, it is not getting exited but goes on assuming those... (3 Replies)
I have folders like as below format. I need to apply the 755 mode for '.sh' format only. I am using the below command to apply the changes. But it's affecting first level only. How to apply the changes recursively in .sh file only?
Please suggest the command.
Thanks
chmod 755 -R *.sh
... (8 Replies)
Discussion started by: k_manimuthu
8 Replies
9. Post Here to Contact Site Administrators and Moderators
Hello Admin/Mods,
I am not sure, if this is the right way to apply, but out of passion, I will go ahead with tje request :)
I want to apply for the role of the Forum Moderator (specially for Shell Programming and Scripting ). I believe I can and will be able to handle the forums and guide... (2 Replies)
I have the following piece of code. Currently the command line arguments are passed as shown below using the "= "sign. I capture the name of the argument, for example vmod and it's corresponding user parameter which is jcdint-z30.cmd.
./raytrac vmod=jcdint-z30.cmd srFile=jcdint.sr
Now I want... (12 Replies)
Hi All,
I need to apply a command to about 40 progs which I have listed in a file called proglist. I tried xargs -n1 -I{} <proglist ssgt {} but the nature of the house written command doesn't like xargs.
Can someone help me with a basic ksh to read my input file line by line and apply a... (3 Replies)
I am using getopt_long to pass arguments to a C++ program. Arguments are passed with a key and a value separated by a space of '=' sign. Some options do not need to assign a value to them.
Example:
./raytrac dist=0.3 --color
I have some classes that need to use some of these... (18 Replies)