Visit The New, Modern Unix Linux Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #988
Difficulty: Medium
OpenBSD developers were instrumental in the creation and development of OpenSSH.
True or False?
Linux & Unix Commands - Search Man Pages

apply(1) [osf1 man page]

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)						      General Commands Manual							  APPLY(1)

NAME
apply - apply a command to a set of arguments SYNOPSIS
apply [ -ac ] [ -n ] command args ... DESCRIPTION
Apply runs the named command on each argument arg in turn. Normally arguments are chosen singly; the optional number n specifies the num- ber of arguments to be passed to command. If n is zero, command is run without arguments once for each arg. 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 arg. If any such sequences occur, n is ignored, and the number of arguments passed to command is the maximum value of d in command. The character `%' may be changed by the -a option. Examples: apply echo * is similar to ls(1); apply -2 cmp a1 b1 a2 b2 ... 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. SEE ALSO
sh(1) AUTHOR
Rob Pike BUGS
Shell metacharacters in command may have bizarre effects; it is best to enclose complicated commands in single quotes ' '. There is no way to pass a literal `%2' if `%' is the argument expansion character. 4.2 Berkeley Distribution April 29, 1985 APPLY(1)

14 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with xargs

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)
Discussion started by: JimJim
4 Replies

2. UNIX for Dummies Questions & Answers

arguments in command line

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)
Discussion started by: rrs
6 Replies

3. Shell Programming and Scripting

command << EOF(dont want to call other script)

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)
Discussion started by: user_prady
4 Replies

4. UNIX for Dummies Questions & Answers

maximum number of arguments

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)
Discussion started by: matrixmadhan
9 Replies

5. UNIX for Dummies Questions & Answers

what the %s does percent sign-s mean?

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)
Discussion started by: ProGrammar
3 Replies

6. UNIX for Dummies Questions & Answers

Passing a command in a variable

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)
Discussion started by: treesloth
3 Replies

7. UNIX for Advanced & Expert Users

Function not called when no arguments is passed

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)
Discussion started by: mac4rfree
3 Replies

8. Shell Programming and Scripting

[Solved] apply 755 mode recursively

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

Application: Want to be Forum Moderator

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)
Discussion started by: knight_eon
2 Replies

10. Programming

Changing the way arguments are read from program

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)
Discussion started by: kristinu
12 Replies

11. UNIX for Dummies Questions & Answers

Help with scripty to read file line by line

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)
Discussion started by: Grueben
3 Replies

12. Programming

Input arguments with C++

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)
Discussion started by: kristinu
18 Replies

13. UNIX for Dummies Questions & Answers

Rm command

(14 Replies)
Discussion started by: Andrshdz
14 Replies

14. UNIX for Dummies Questions & Answers

Need help in command

(2 Replies)
Discussion started by: arun888
2 Replies

Featured Tech Videos