Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

apply(1) [mojave 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

Check Out this Related 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)
Man Page

15 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

variable vlaues in other files

lets say i have a command with arguments i.e. alt_disk_install -C hdisk1 the argument being hdisk1 this could be differnt depending on what server your on how could i have this be a variable that refers to this value in a file something like alt_disk_install -C valueinfile ... (4 Replies)
Discussion started by: csaunders
4 Replies

2. Shell Programming and Scripting

compare file sizes

Is there a command that will return the name of the largest file within a directory? If so, can I set the returned filename into a variable? (4 Replies)
Discussion started by: joli
4 Replies

3. Shell Programming and Scripting

Getting error in command line arguments

Hi, When i am running the following script 1.sh (without giving the command line arguments) then i am getting the following error. if then echo "UID and PWD are correct" elif then echo "Either UID or PWD is wrong. Please check your UID and PWD" else echo "UID and PWD can't be blank"... (9 Replies)
Discussion started by: sunitachoudhury
9 Replies

4. Shell Programming and Scripting

list all file whose 2nd char is digit!

how to list all files in current directory whose second character is a digit. i guess i hav to use grep command + ls for this. but dont know how to use? (6 Replies)
Discussion started by: Sgupta
6 Replies

5. Shell Programming and Scripting

editing files

Is there any command which I can apply from the command line to find and replace a particular text say "00:00:00:00" with "00" from all the files( where ever this text exists) of the current directory? (17 Replies)
Discussion started by: cobroraj
17 Replies

6. Shell Programming and Scripting

Change all filenames in a directory

I have a directory of files and each file has a random 5 digit string at the beginning that needs to be removed. Plus, there are some files that will be identically named after the 5 digit string is removed and I want those eliminated or moved. any ideas? (17 Replies)
Discussion started by: crumb
17 Replies

7. Shell Programming and Scripting

counter in case similar name occure

Good morning everybody I have a variable file (mean the data inside the file keep changing in frequent basis) and I want to develop a script to count if we get 3 similar names except last digit (xxxxA, xxxxB, xxxxC) and counter will be reset if one of the name is disappear. details: ... (2 Replies)
Discussion started by: Bluetoot
2 Replies

8. UNIX for Dummies Questions & Answers

Bourne Shell Script that only takes command line arguments

Does anybody know how to Accept a “userid” as a command line argument on a Unix Bourne Shell Script? The output should be something like this: User userid has a home directory of /path/directory the default shell for this user is /path/shell (5 Replies)
Discussion started by: ajaira
5 Replies

9. Shell Programming and Scripting

Print arguments with the help of variable

Let's say I want to print the arguments $4 till $#, how can I do this? $# contains the number of arguments $@ contain all the arguments as string What i need is something like for i in $4_till_$#; do #do something with $i convert $i ~/$output done The first 3 arguments are used as options... (6 Replies)
Discussion started by: hakermania
6 Replies

10. Shell Programming and Scripting

Multiple command execution

I want to open more than 2 files(f1,f2). commands for opening those files are stored in one file (f3). command to execute the file (f3). (3 Replies)
Discussion started by: Mahendravarma
3 Replies

11. 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

12. Shell Programming and Scripting

Passing gunzipped filename to a variable

Hi , Am trying to gunzip a file and pass the gunzipped file name to a variable , but its not taking up the value. Am trying to execute the command f=`gunzip <filename>`;echo $f. Here the file is getting gunzipped but the file name is not assigned to the variable. Any help on this will be useful.... (5 Replies)
Discussion started by: rogerben
5 Replies

13. Homework & Coursework Questions

Finding the directories with same permission and then apply some default UNIX commands

Write a Unix shell script named 'mode' that accepts two or more arguments, a file mode, a command and an optional list of parameters and performs the given command with the optional parameters on all files with that given mode. For example, mode 644 ls -l should perform the command ls -l on all... (5 Replies)
Discussion started by: femchi
5 Replies

14. Shell Programming and Scripting

Repeat a command for one sec

How to repeat the execution of a simple command like the following for 1 sec ? echo Hi The completion time for the command is not known, but we need to calculate the number of times this commans executes successfully within 1 sec. Thanks Kumarjit (5 Replies)
Discussion started by: kumarjt
5 Replies

15. Shell Programming and Scripting

Check variable

Hi people, I would like to start a review of my config variable to check whether they have been changed and if not then there is only an echo. If they have been changed to my other commands are executed. I hope you can help me. with best regards JPad edit: here my code if ;... (8 Replies)
Discussion started by: JPad
8 Replies